re PR rtl-optimization/49799 (gcc arm generates illegal sbfx instruction)
authorWei Guozhi <carrot@google.com>
Fri, 29 Jul 2011 01:27:29 +0000 (01:27 +0000)
committerWei Guozhi <carrot@gcc.gnu.org>
Fri, 29 Jul 2011 01:27:29 +0000 (01:27 +0000)
PR rtl-optimization/49799

* combine.c (make_compound_operation): Check if the bit field is valid
before change it to bit field extraction.

* gcc.dg/pr49799.c: New test case.

From-SVN: r176911

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr49799.c [new file with mode: 0644]

index c304e8245b6cd49abe09fac242a7983afcc07785..0b70415acad0e9684e65e6a1003d277aba4ecdc5 100644 (file)
@@ -1,3 +1,9 @@
+2011-07-29  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.
+
 2011-07-29  Bernd Schmidt  <bernds@codesourcery.com>
 
        PR rtl-optimization/49891
index 4dbf022fd1be5b6e6dabb0b8470055fab43cfb87..b5cf245f761ca1388bcf065ef7c41e13f9a4d3ec 100644 (file)
@@ -7787,6 +7787,7 @@ make_compound_operation (rtx x, enum rtx_code in_code)
          && 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 85daf9f7092b388ac9525f30c3b8c0e12068665b..d5e61cb5e8b840febd156cb36b1e44c4b3ea7dc7 100644 (file)
@@ -1,3 +1,8 @@
+2011-07-29  Wei Guozhi  <carrot@google.com>
+
+       PR rtl-optimization/49799
+       * gcc.dg/pr49799.c: New test case.
+
 2011-07-22  Sebastian Pop  <sebastian.pop@amd.com>
 
        PR middle-end/48648
diff --git a/gcc/testsuite/gcc.dg/pr49799.c b/gcc/testsuite/gcc.dg/pr49799.c
new file mode 100644 (file)
index 0000000..61ac261
--- /dev/null
@@ -0,0 +1,25 @@
+/* PR rtl-optimization/49799 */
+/* { dg-do assemble } */
+/* { dg-options "-O2 -w" } */
+
+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;
+}