This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Ping: PR tree-opt/33615 [1/2] Hoisting of throwing expression for -fnon-call-exceptions
- From: Zdenek Dvorak <rakdver at kam dot mff dot cuni dot cz>
- To: Richard Sandiford <rsandifo at nildram dot co dot uk>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 8 Oct 2007 02:48:47 +0200
- Subject: Re: Ping: PR tree-opt/33615 [1/2] Hoisting of throwing expression for -fnon-call-exceptions
- References: <87wsty69os.fsf@firetop.home>
Hello,
> http://gcc.gnu.org/ml/gcc-patches/2007-10/msg00085.html
>
> This didn't draw any comment from maintainers. Andrew commented that it
> might be a good idea to set TREE_SIDE_EFFECTS for things that can throw,
> but I don't know whether that'd be easier to maintain than the new
> (function) predicate suggested in the covering patch. Either way,
> I hope the patch as-is is strict progress.
the patch is OK, but see the notes below.
> Index: gcc/tree-ssa-loop-im.c
> ===================================================================
> --- gcc/tree-ssa-loop-im.c 2007-10-01 23:23:16.000000000 +0100
> +++ gcc/tree-ssa-loop-im.c 2007-10-01 23:39:36.000000000 +0100
> @@ -260,7 +260,8 @@ movement_possibility (tree stmt)
>
> rhs = GIMPLE_STMT_OPERAND (stmt, 1);
>
> - if (TREE_SIDE_EFFECTS (rhs))
> + if (TREE_SIDE_EFFECTS (rhs)
> + || tree_could_throw_p (rhs))
> return MOVE_IMPOSSIBLE;
>
> if (TREE_CODE (lhs) != SSA_NAME
The check for
if (stmt_ends_bb_p (stmt))
return MOVE_IMPOSSIBLE;
was supposed to prevent this optimization for expressions throwing
exceptions. However, we do not create edges to exit for exceptions that
are not caught locally; which seems somewhat wrong, certainly this
can cause problems also for other code hoisting optimizations.
Zdenek