[PATCH] Fix store motion with -fnon-call-exceptions (PR tree-optimization/46864)
Richard Guenther
richard.guenther@gmail.com
Fri Dec 10 09:58:00 GMT 2010
On Thu, Dec 9, 2010 at 11:03 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> Until GCC 4.4 EH edges were EDGE_ABNORMAL, so execute_sm wasn't doing
> anything on possibly trapping stores with -fnon-call-exceptions
> and it certainly isn't prepared to do so (both to get rid of the old EH
> edges and adding new ones).
>
> This patch fixes it just by restoring sm behavior to the 4.4 and earlier
> state, without -fnon-call-exceptions I believe it will very rarely make a
> difference, throw in a loop will be outside of the loop bbs and a call that
> can throw will likely make the stores loop dependent. Bootstrapped/regtested
> on x86_64-linux and i686-linux, ok for trunk?
Ok.
Thanks,
Richard.
> 2010-12-09 Jakub Jelinek <jakub@redhat.com>
>
> PR tree-optimization/46864
> * tree-ssa-loop-im.c (loop_suitable_for_sm): Return false even
> when there are EDGE_EH exit edges.
>
> * g++.dg/opt/pr46864.C: New test.
>
> --- gcc/tree-ssa-loop-im.c.jj 2010-11-01 09:07:22.000000000 +0100
> +++ gcc/tree-ssa-loop-im.c 2010-12-09 16:05:40.000000000 +0100
> @@ -2369,7 +2369,7 @@ loop_suitable_for_sm (struct loop *loop
> edge ex;
>
> FOR_EACH_VEC_ELT (edge, exits, i, ex)
> - if (ex->flags & EDGE_ABNORMAL)
> + if (ex->flags & (EDGE_ABNORMAL | EDGE_EH))
> return false;
>
> return true;
> --- gcc/testsuite/g++.dg/opt/pr46864.C.jj 2010-12-09 16:13:56.000000000 +0100
> +++ gcc/testsuite/g++.dg/opt/pr46864.C 2010-12-09 16:13:32.000000000 +0100
> @@ -0,0 +1,26 @@
> +// PR tree-optimization/46864
> +// { dg-do compile }
> +// { dg-options "-O -fnon-call-exceptions" }
> +
> +int baz ();
> +
> +struct S
> +{
> + int k;
> + bool bar () throw ()
> + {
> + int m = baz ();
> + for (int i = 0; i < m; i++)
> + k = i;
> + return m;
> + }
> +};
> +
> +extern S *s;
> +
> +void
> +foo ()
> +{
> + while (baz () && s->bar ())
> + ;
> +}
>
> Jakub
>
More information about the Gcc-patches
mailing list