PR tree-opt/33615 [2/2] Hoisting of throwing expression for -fnon-call-exceptions
Daniel Berlin
dberlin@dberlin.org
Tue Oct 2 01:35:00 GMT 2007
On 10/1/07, Richard Sandiford <rsandifo@nildram.co.uk> wrote:
> Following on from:
>
> http://gcc.gnu.org/ml/gcc-patches/2007-10/msg00085.html
>
> this second patch fixes the PRE case. Bootstrapped & regression-tested
> on x86_64-linux-gnu. Also regression-tested on mipsisa32-elf. OK to
> install?
Sure (but ugh, all these tests predicates should be in a single
"can_move_stmt_p" function)
>
> Richard
>
>
> 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.
>
> Index: gcc/tree-ssa-pre.c
> ===================================================================
> --- gcc/tree-ssa-pre.c 2007-10-01 23:23:08.000000000 +0100
> +++ gcc/tree-ssa-pre.c 2007-10-01 23:44:10.000000000 +0100
> @@ -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;
> Index: gcc/testsuite/g++.dg/tree-ssa/pr33615-2.C
> ===================================================================
> --- /dev/null 2007-09-27 09:37:00.556097250 +0100
> +++ gcc/testsuite/g++.dg/tree-ssa/pr33615-2.C 2007-10-01 23:44:10.000000000 +0100
> @@ -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" } }
>
More information about the Gcc-patches
mailing list