re PR tree-optimization/67470 (ICE at -O3 on x86_64-linux-gnu in compute_live_loop_ex...
authorRichard Biener <rguenther@suse.de>
Tue, 15 Sep 2015 14:10:10 +0000 (14:10 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 15 Sep 2015 14:10:10 +0000 (14:10 +0000)
2015-09-15  Richard Biener  <rguenther@suse.de>

PR tree-optimization/67470
* tree-ssa-loop-im.c (execute_sm_if_changed): Preserve PHI
structure for PHI hoisting by inserting a forwarder block
if appropriate.

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

From-SVN: r227797

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr67470.c [new file with mode: 0644]
gcc/tree-ssa-loop-im.c

index fda0151c22e017307cad0cf9cf89dbe49b194689..bc00735e07f35b40f675ba4fbb5f272f68bc31f0 100644 (file)
@@ -1,3 +1,10 @@
+2015-09-15  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/67470
+       * tree-ssa-loop-im.c (execute_sm_if_changed): Preserve PHI
+       structure for PHI hoisting by inserting a forwarder block
+       if appropriate.
+
 2015-09-15  Christian Bruel  <christian.bruel@st.com>
 
        * config/arm/arm.c (TARGET_OPTION_PRINT): Define.
index 6cea108480075c711c3057fb6a36cef4d1d884e5..c8aa20a73a1f5efe12bd7a8c0a57e7045763ee78 100644 (file)
@@ -1,3 +1,8 @@
+2015-09-15  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/67470
+       * gcc.dg/torture/pr67470.c: New testcase.
+
 2015-09-15  Alan Lawrence  <alan.lawrence@arm.com>
 
        * gcc.target/aarch64/vect_int32x2x4_1.c: New.
diff --git a/gcc/testsuite/gcc.dg/torture/pr67470.c b/gcc/testsuite/gcc.dg/torture/pr67470.c
new file mode 100644 (file)
index 0000000..29a23c2
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+
+int a, b, *c, d, e;
+
+void abort (void);
+
+int
+main ()
+{
+  int f, *g, **h = &g;
+  for (; b;)
+    {
+      c = &a;
+      for (e = 0; e < 1; e++)
+       *h = 0;
+      for (; d; d++)
+       if (f)
+         *c = 0;
+       else
+         {
+           *c = e = 0;
+           *h = &a;
+         }
+
+      if (a && !g)
+       abort ();
+
+    }
+  return 0;
+}
index f1d4a8ce15cc08428fab27bcb4b233b9e0f0e29f..f67b57d7f27e9d5b620350049a906c166e04a2f3 100644 (file)
@@ -1839,6 +1839,23 @@ execute_sm_if_changed (edge ex, tree mem, tree tmp_var, tree flag)
 
   if (loop_has_only_one_exit)
     ex = split_block_after_labels (ex->dest);
+  else
+    {
+      for (gphi_iterator gpi = gsi_start_phis (ex->dest);
+          !gsi_end_p (gpi); gsi_next (&gpi))
+       {
+         gphi *phi = gpi.phi ();
+         if (virtual_operand_p (gimple_phi_result (phi)))
+           continue;
+
+         /* When the destination has a non-virtual PHI node with multiple
+            predecessors make sure we preserve the PHI structure by
+            forcing a forwarder block so that hoisting of that PHI will
+            still work.  */
+         split_edge (ex);
+         break;
+       }
+    }
 
   old_dest = ex->dest;
   new_bb = split_edge (ex);