re PR tree-optimization/43629 (Struct to register optimization fails)

2010-04-07  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/43629
	* tree-ssa-ccp.c (likely_value): Properly look for constant
	values.  Reset all_undefined_operands if we have seen a
	constant value.

	* gcc.c-torture/execute/pr43629.c: New testcase.

From-SVN: r158070
This commit is contained in:
Richard Guenther 2010-04-07 15:40:43 +00:00 committed by Richard Biener
parent 7454e02cc5
commit 247bc1c03f
4 changed files with 42 additions and 0 deletions

View File

@ -1,3 +1,10 @@
2010-04-07 Richard Guenther <rguenther@suse.de>
PR tree-optimization/43629
* tree-ssa-ccp.c (likely_value): Properly look for constant
values. Reset all_undefined_operands if we have seen a
constant value.
2010-04-06 Jakub Jelinek <jakub@redhat.com>
PR target/43638

View File

@ -1,3 +1,8 @@
2010-04-07 Richard Guenther <rguenther@suse.de>
PR tree-optimization/43629
* gcc.c-torture/execute/pr43629.c: New testcase.
2010-04-06 Jakub Jelinek <jakub@redhat.com>
* gcc.target/s390/stackcheck1.c: Add dg-warning.

View File

@ -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;
}

View File

@ -505,6 +505,7 @@ likely_value (gimple stmt)
bool has_constant_operand, has_undefined_operand, all_undefined_operands;
tree use;
ssa_op_iter iter;
unsigned i;
enum gimple_code code = gimple_code (stmt);
@ -559,6 +560,22 @@ likely_value (gimple stmt)
has_constant_operand = true;
}
/* There may be constants in regular rhs operands. For calls we
have to ignore lhs, fndecl and static chain, otherwise only
the lhs. */
for (i = (is_gimple_call (stmt) ? 2 : 0) + gimple_has_lhs (stmt);
i < gimple_num_ops (stmt); ++i)
{
tree op = gimple_op (stmt, i);
if (!op || TREE_CODE (op) == SSA_NAME)
continue;
if (is_gimple_min_invariant (op))
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. */