re PR tree-optimization/63380 (Wrong constant folding)

2014-10-09  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/63380
	* tree-ssa-tail-merge.c (stmt_local_def): Exclude stmts that
	may trap.

	* gcc.dg/torture/pr63380-1.c: New testcase.
	* gcc.dg/torture/pr63380-2.c: Likewise.

From-SVN: r216038
This commit is contained in:
Richard Biener 2014-10-09 12:45:07 +00:00 committed by Richard Biener
parent 3b7ea188c0
commit 12d3031b2c
5 changed files with 40 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2014-10-09 Richard Biener <rguenther@suse.de>
PR tree-optimization/63380
* tree-ssa-tail-merge.c (stmt_local_def): Exclude stmts that
may trap.
2014-10-09 Joern Rennecke <joern.rennecke@embecosm.com>
* config/avr/avr.opt (mmcu=): Change to have a string value.

View File

@ -1,3 +1,9 @@
2014-10-09 Richard Biener <rguenther@suse.de>
PR tree-optimization/63380
* gcc.dg/torture/pr63380-1.c: New testcase.
* gcc.dg/torture/pr63380-2.c: Likewise.
2014-10-09 Marek Polacek <polacek@redhat.com>
PR c/63480

View File

@ -0,0 +1,15 @@
/* { dg-do run } */
int a = 0, b = 1, c = 0, d = 1, e, f, g, h;
int
main ()
{
e = 1 >> d;
f = ((31 / (1 > e)) || c) / 2;
g = b || a;
h = 31 / g;
if (!h)
__builtin_abort();
return 0;
}

View File

@ -0,0 +1,10 @@
/* { dg-do run } */
int a = 0, b = 0, c = 0, d, e;
int
main (void)
{
d = ((20 % (1 != b)) && c) + 2147483647;
e = 20 % (a >= 0);
return 0;
}

View File

@ -313,9 +313,9 @@ stmt_local_def (gimple stmt)
tree val;
def_operand_p def_p;
if (gimple_has_side_effects (stmt)
|| stmt_could_throw_p (stmt)
|| gimple_vdef (stmt) != NULL_TREE)
if (gimple_vdef (stmt) != NULL_TREE
|| gimple_has_side_effects (stmt)
|| gimple_could_trap_p_1 (stmt, false, false))
return false;
def_p = SINGLE_SSA_DEF_OPERAND (stmt, SSA_OP_DEF);