tree-optimization/96491 - avoid store commoning across abnormal edges
authorRichard Biener <rguenther@suse.de>
Thu, 6 Aug 2020 10:18:24 +0000 (12:18 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 6 Aug 2020 10:19:48 +0000 (12:19 +0200)
This avoids store commoning across abnormal edges since that easily
can disrupt abnormal coalescing because it might create overlapping
lifetime of variables.

2020-08-06  Richard Biener  <rguenther@suse.de>

PR tree-optimization/96491
* tree-ssa-sink.c (sink_common_stores_to_bb): Avoid
sinking across abnormal edges.

* gcc.dg/torture/pr96491.c: New testcase.

gcc/testsuite/gcc.dg/torture/pr96491.c [new file with mode: 0644]
gcc/tree-ssa-sink.c

diff --git a/gcc/testsuite/gcc.dg/torture/pr96491.c b/gcc/testsuite/gcc.dg/torture/pr96491.c
new file mode 100644 (file)
index 0000000..784559f
--- /dev/null
@@ -0,0 +1,29 @@
+/* { dg-do compile }  */
+
+int rj;
+
+void __attribute__ ((returns_twice))
+da (void)
+{
+  rj = 1;
+}
+
+void
+c5 (void)
+{
+  for (;;)
+    ++rj;
+}
+
+void
+ls (int kz)
+{
+  if (kz == 0)
+    {
+      rj = 0;
+      c5 ();
+    }
+
+  da ();
+  c5 ();
+}
index 962ad07..4cc5195 100644 (file)
@@ -503,7 +503,8 @@ sink_common_stores_to_bb (basic_block bb)
              tree arg = gimple_phi_arg_def (phi, i);
              gimple *def = SSA_NAME_DEF_STMT (arg);
              if (! is_gimple_assign (def)
-                 || stmt_can_throw_internal (cfun, def))
+                 || stmt_can_throw_internal (cfun, def)
+                 || (gimple_phi_arg_edge (phi, i)->flags & EDGE_ABNORMAL))
                {
                  /* ???  We could handle some cascading with the def being
                     another PHI.  We'd have to insert multiple PHIs for