This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix store motion with -fnon-call-exceptions (PR tree-optimization/46864)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 9 Dec 2010 23:03:06 +0100
- Subject: [PATCH] Fix store motion with -fnon-call-exceptions (PR tree-optimization/46864)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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?
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