From: Richard Guenther Date: Tue, 20 Apr 2010 13:08:01 +0000 (+0000) Subject: re PR tree-optimization/43629 (Struct to register optimization fails) X-Git-Tag: releases/gcc-4.3.5~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=914f42cb388553353d39522c816086f42be33685;p=thirdparty%2Fgcc.git re PR tree-optimization/43629 (Struct to register optimization fails) 2010-04-20 Richard Guenther PR tree-optimization/43629 * tree-ssa-ccp.c (likely_value): Scan for literal constants as well. Reset all_undefined_operands if we have seen a constant value. * gcc.c-torture/execute/pr43629.c: New testcase. From-SVN: r158554 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3126b7d086a1..c8d59b35b91c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2010-04-20 Richard Guenther + + PR tree-optimization/43629 + * tree-ssa-ccp.c (likely_value): Scan for literal constants + as well. Reset all_undefined_operands if we have seen a + constant value. + 2010-04-18 Eric Botcazou PR tree-optimization/43769 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e0a2d40effbd..bbbee43d9860 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-04-20 Richard Guenther + + PR tree-optimization/43629 + * gcc.c-torture/execute/pr43629.c: New testcase. + 2010-04-18 Eric Botcazou * gnat.dg/rep_clause5.ad[sb]: New test. diff --git a/gcc/testsuite/gcc.c-torture/execute/pr43629.c b/gcc/testsuite/gcc.c-torture/execute/pr43629.c new file mode 100644 index 000000000000..10c0196c89bd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr43629.c @@ -0,0 +1,13 @@ +int flag; +extern void abort (void); +int main() +{ + int x; + if (flag) + x = -1; + else + x &= 0xff; + if (x & ~0xff) + abort (); + return 0; +} diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 08a9ae4d2794..41eed535d50e 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -569,6 +569,34 @@ likely_value (tree stmt) has_constant_operand = true; } + if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT) + { + tree rhs = GIMPLE_STMT_OPERAND (stmt, 1); + if (REFERENCE_CLASS_P (rhs)) + { + if (is_gimple_min_invariant (TREE_OPERAND (rhs, 0))) + has_constant_operand = true; + } + else if (EXPR_P (rhs)) + { + unsigned i; + for (i = 0; i < TREE_CODE_LENGTH (TREE_CODE (rhs)); ++i) + if (TREE_OPERAND (rhs, i) + && is_gimple_min_invariant (TREE_OPERAND (rhs, i))) + has_constant_operand = true; + } + } + else if (TREE_CODE (stmt) == CALL_EXPR) + { + unsigned i; + for (i = 0; i < call_expr_nargs (stmt); ++i) + if (is_gimple_min_invariant (CALL_EXPR_ARG (stmt, i))) + has_constant_operand = true; + } + + if (has_constant_operand) + all_undefined_operands = false; + /* If the operation combines operands like COMPLEX_EXPR make sure to not mark the result UNDEFINED if only one part of the result is undefined. */