re PR tree-optimization/64183 (Complete unroll doesn't happen for a while-loop)
authorMarek Polacek <polacek@redhat.com>
Sat, 6 Dec 2014 13:10:31 +0000 (13:10 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Sat, 6 Dec 2014 13:10:31 +0000 (13:10 +0000)
PR tree-optimization/64183
* c-gimplify.c (c_gimplify_expr): Don't convert the RHS of a
shift-expression if it is integer_type_node.  Use types_compatible_p.

* gcc.dg/tree-ssa/pr64183.c: New test.

From-SVN: r218447

gcc/c-family/ChangeLog
gcc/c-family/c-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr64183.c [new file with mode: 0644]

index ca3e0b36bab4da8d45d74bf9d76b3baa044ac025..1cb8968c38fb7ca8fae62be1dac71933ea1ec4bb 100644 (file)
@@ -1,3 +1,9 @@
+2014-12-06  Marek Polacek  <polacek@redhat.com>
+
+       PR tree-optimization/64183
+       * c-gimplify.c (c_gimplify_expr): Don't convert the RHS of a
+       shift-expression if it is integer_type_node.  Use types_compatible_p.
+
 2014-11-29  Jakub Jelinek  <jakub@redhat.com>
 
        * c-common.c (convert_vector_to_pointer_for_subscript): Remove NULL
index 2cfa5d96a65a17fa99c0a472e5030ed92632c054..4781cf24c6437f6022812d3f2d69d0e2da4d0d9b 100644 (file)
@@ -255,7 +255,10 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED,
           type demotion/promotion pass.  */
        tree *op1_p = &TREE_OPERAND (*expr_p, 1);
        if (TREE_CODE (TREE_TYPE (*op1_p)) != VECTOR_TYPE
-           && TYPE_MAIN_VARIANT (TREE_TYPE (*op1_p)) != unsigned_type_node)
+           && !types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (*op1_p)),
+                                   unsigned_type_node)
+           && !types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (*op1_p)),
+                                   integer_type_node))
          *op1_p = convert (unsigned_type_node, *op1_p);
        break;
       }
index 4ea2dfe9dcfbce02ee9811004b41c4ab2d7ca5b2..abeacd0a55d6105b00084e6a7d6c01c4e7c89f13 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-06  Marek Polacek  <polacek@redhat.com>
+
+       PR tree-optimization/64183
+       * gcc.dg/tree-ssa/pr64183.c: New test.
+
 2014-12-06  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/64200
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr64183.c b/gcc/testsuite/gcc.dg/tree-ssa/pr64183.c
new file mode 100644 (file)
index 0000000..0563739
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-cunroll-details" } */
+
+int bits;
+unsigned int size;
+int max_code;
+
+void
+test ()
+{
+ int code = 0;
+
+ while (code < max_code)
+   code |= ((unsigned int) (size >> (--bits)));
+
+ while (bits < (unsigned int)25)
+   bits += 8;
+}
+
+/* { dg-final { scan-tree-dump "Loop 2 iterates at most 4 times" "cunroll"} } */
+/* { dg-final { cleanup-tree-dump "cunroll" } } */