re PR tree-optimization/33615 (Hoisting of potentially-throwing values for -fnon-call-exceptions)

gcc/
	PR tree-optimization/33615
	* tree-ssa-pre.c (compute_avail): Don't call make_values_for_stmt
	if the statement might throw.  Fix formatting.

gcc/testsuite/
	PR tree-optimization/33615
	* g++.dg/tree-ssa/pr33615-2.C: New test.

From-SVN: r129164
This commit is contained in:
Richard Sandiford 2007-10-09 11:05:33 +00:00 committed by Richard Sandiford
parent 9417287694
commit 05c42b11e6
4 changed files with 36 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2007-10-09 Richard Sandiford <rsandifo@nildram.co.uk>
PR tree-optimization/33615
* tree-ssa-pre.c (compute_avail): Don't call make_values_for_stmt
if the statement might throw. Fix formatting.
2007-10-09 Richard Sandiford <rsandifo@nildram.co.uk>
PR tree-optimization/33615

View File

@ -1,3 +1,8 @@
2007-10-09 Richard Sandiford <rsandifo@nildram.co.uk>
PR tree-optimization/33615
* g++.dg/tree-ssa/pr33615-2.C: New test.
2007-10-09 Richard Sandiford <rsandifo@nildram.co.uk>
PR tree-optimization/33615

View File

@ -0,0 +1,20 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fnon-call-exceptions -fdump-tree-pre-details -w" } */
extern volatile int y;
double
foo (double a, int x)
{
while (x--)
{
y++;
a += 1.0 / 0.0;
}
return a;
}
// The expression 1.0 / 0.0 should not be treated as a loop invariant
// if it may throw an exception.
// { dg-final { scan-tree-dump-times "Replaced 1\\\.0e\\\+0 / 0\\\.0" 0 "pre" } }
// { dg-final { cleanup-tree-dump "pre" } }

View File

@ -3555,10 +3555,11 @@ compute_avail (void)
}
else if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT
&& !ann->has_volatile_ops
&& TREE_CODE (GIMPLE_STMT_OPERAND (stmt, 0)) == SSA_NAME
&& !SSA_NAME_OCCURS_IN_ABNORMAL_PHI
(GIMPLE_STMT_OPERAND (stmt, 0)))
&& !ann->has_volatile_ops
&& TREE_CODE (GIMPLE_STMT_OPERAND (stmt, 0)) == SSA_NAME
&& (!SSA_NAME_OCCURS_IN_ABNORMAL_PHI
(GIMPLE_STMT_OPERAND (stmt, 0)))
&& !tree_could_throw_p (stmt))
{
if (make_values_for_stmt (stmt, block))
continue;