This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR49799: Don't generate illegal bit field extraction instruction


Test case added.

Tested with
make check-gcc RUNTESTFLAGS="--target_board=arm-sim/thumb/arch=armv7-a
arm.exp=pr49799.c"
make check-gcc RUNTESTFLAGS="--target_board=arm-sim/arch=armv7-a
arm.exp=pr49799.c"

It fails without this patch and passes with this patch.

OK for trunk and 4.6 now?

thanks
Carrot

ChangeLog:
2011-07-28  Wei Guozhi  <carrot@google.com>

        PR rtl-optimization/49799
        * combine.c (make_compound_operation): Check if the bit field is valid
        before change it to bit field extraction.


ChangeLog:
2011-07-28  Wei Guozhi  <carrot@google.com>

        PR rtl-optimization/49799
        * pr49799.c : New test case.


Index: gcc/combine.c
===================================================================
--- gcc/combine.c	(revision 176733)
+++ gcc/combine.c	(working copy)
@@ -7787,6 +7787,7 @@ make_compound_operation (rtx x, enum rtx
 	  && GET_CODE (lhs) == ASHIFT
 	  && CONST_INT_P (XEXP (lhs, 1))
 	  && INTVAL (rhs) >= INTVAL (XEXP (lhs, 1))
+	  && INTVAL (XEXP (lhs, 1)) >= 0
 	  && INTVAL (rhs) < mode_width)
 	{
 	  new_rtx = make_compound_operation (XEXP (lhs, 0), next_code);


Index: pr49799.c
===================================================================
--- pr49799.c	(revision 0)
+++ pr49799.c	(revision 0)
@@ -0,0 +1,25 @@
+/* PR rtl-optimization/49799 */
+/* { dg-do assemble } */
+/* { dg-options "-O2 -w -march=armv7-a" } */
+
+static __inline int bar(int a)
+{
+    int tmp;
+
+    if (a <= 0) a ^= 0xFFFFFFFF;
+
+    return tmp - 1;
+}
+
+void foo(short *K)
+{
+    short tmp;
+    short *pptr, P[14];
+
+    pptr = P;
+    tmp = bar(*K);
+    *pptr = (*K << tmp) >> 16;
+
+    if (*P < tmp)
+        *K++ = 0;
+}


On Thu, Jul 28, 2011 at 4:04 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Jul 28, 2011 at 03:38:07PM +0800, Carrot Wei wrote:
>> OK for trunk and 4.6?
>>
>> ChangeLog:
>> 2011-07-28 ?Wei Guozhi ?<carrot@google.com>
>>
>> ? ? ? ? PR rtl-optimization/49799
>> ? ? ? ? * combine.c (make_compound_operation): Check if the bit field is valid
>> ? ? ? ? before change it to bit field extraction.
>
> Looks good to me, handling SHIFT_COUNT_TRUNCATED here isn't IMHO necessary
> and the checking whether shift count is in the right range matches other rtx
> simplifications (e.g. in simplify-rtx.c).
> Though, you should add a testcase, probably
> /* PR rtl-optimization/49799 */
> /* { dg-do assemble } */
> /* { dg-options "-O2 -w" } */
>
> plus not sure if for arm you don't want to force this -march=armv7-a
> into dg-options too or just leave it as is.
>
> ? ? ? ?Jakub
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]