From: Marek Polacek Date: Sat, 6 Dec 2014 13:10:31 +0000 (+0000) Subject: re PR tree-optimization/64183 (Complete unroll doesn't happen for a while-loop) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7fb66c15276446a48da02af39fb5d3e363ef8e32;p=gcc.git re PR tree-optimization/64183 (Complete unroll doesn't happen for a while-loop) 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 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index ca3e0b36bab..1cb8968c38f 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2014-12-06 Marek Polacek + + 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 * c-common.c (convert_vector_to_pointer_for_subscript): Remove NULL diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c index 2cfa5d96a65..4781cf24c64 100644 --- a/gcc/c-family/c-gimplify.c +++ b/gcc/c-family/c-gimplify.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4ea2dfe9dcf..abeacd0a55d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-12-06 Marek Polacek + + PR tree-optimization/64183 + * gcc.dg/tree-ssa/pr64183.c: New test. + 2014-12-06 H.J. Lu 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 index 00000000000..0563739c169 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr64183.c @@ -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" } } */