re PR target/82386 (internal compiler error: Segmentation fault on 32-bit powerpc...
authorJakub Jelinek <jakub@redhat.com>
Tue, 3 Oct 2017 09:49:37 +0000 (11:49 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 3 Oct 2017 09:49:37 +0000 (11:49 +0200)
PR target/82386
* combine.c (combine_instructions): Don't combine in unreachable
basic blocks.

* gcc.dg/pr82386.c: New test.

From-SVN: r253378

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr82386.c [new file with mode: 0644]

index c0b2f2b1c6d888add78d942082b64f3055447a64..934dd76fa8593c33f635bb8a11c60a93b149f958 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/82386
+       * combine.c (combine_instructions): Don't combine in unreachable
+       basic blocks.
+
 2017-08-18  Peter Bergner  <bergner@vnet.ibm.com>
 
        PR target/80210
index e502fa147267d071adc0e47764ad8ded56ca0683..400cef3495a3faf08f7267765991bf278a1c5128 100644 (file)
@@ -1232,6 +1232,12 @@ combine_instructions (rtx_insn *f, unsigned int nregs)
   FOR_EACH_BB_FN (this_basic_block, cfun)
     {
       rtx_insn *last_combined_insn = NULL;
+
+      /* Ignore instruction combination in basic blocks that are going to
+        be removed as unreachable anyway.  See PR82386.  */
+      if (EDGE_COUNT (this_basic_block->preds) == 0)
+       continue;
+
       optimize_this_for_speed_p = optimize_bb_for_speed_p (this_basic_block);
       last_call_luid = 0;
       mem_last_set = -1;
index 004af663545908bc8a3be03ebcca3785f4b48d85..74023abc015ae1c35e6394b680b09d365c8f9e39 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/82386
+       * gcc.dg/pr82386.c: New test.
+
 2017-10-02  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/70570
diff --git a/gcc/testsuite/gcc.dg/pr82386.c b/gcc/testsuite/gcc.dg/pr82386.c
new file mode 100644 (file)
index 0000000..8901f2b
--- /dev/null
@@ -0,0 +1,38 @@
+/* PR target/82386 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -w" } */
+/* { dg-additional-options "-misel" { target powerpc*-*-* } } */
+
+long long int fs;
+int vm;
+
+void
+sd (void)
+{
+  fs = 1;
+  vm = 2;
+  goto zf;
+
+  if (0)
+    {
+      int y6 = 0;
+      int *uu = &y6;
+      short int he;
+      int of = 0;
+
+ zf:
+      for (;;)
+      {
+          he = of;
+          if (he || (fs |= vm))
+            {
+              *uu = fs;
+              fs += vm;
+            }
+          if (y6 == vm)
+            fs |= he;
+          he = y6 || fs;
+          fs /= 0;
+        }
+    }
+}