From 05c42b11e64489819f65e0daec4679f311ec3632 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Tue, 9 Oct 2007 11:05:33 +0000 Subject: 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 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/tree-ssa/pr33615-2.C | 20 ++++++++++++++++++++ gcc/tree-ssa-pre.c | 9 +++++---- 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr33615-2.C (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1d66ea3..43c2c9d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,12 @@ 2007-10-09 Richard Sandiford 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 + + PR tree-optimization/33615 * tree-ssa-loop-im.c (movement_possibility): Return MOVE_IMPOSSIBLE if the rhs might throw. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f6665d5..61dd6de 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2007-10-09 Richard Sandiford PR tree-optimization/33615 + * g++.dg/tree-ssa/pr33615-2.C: New test. + +2007-10-09 Richard Sandiford + + PR tree-optimization/33615 * g++.dg/tree-ssa/pr33615.C: New test. 2007-10-08 Alexandre Oliva diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr33615-2.C b/gcc/testsuite/g++.dg/tree-ssa/pr33615-2.C new file mode 100644 index 0000000..542731a --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr33615-2.C @@ -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" } } diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 33c44ee..6203467 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -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; -- cgit v1.1