This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed] Fix combiner ICE with unconditional traps (PR target/82386)


Hi!

LOG_LINKS normally are just within a basic block and various parts of
the combiner assume that this_basic_block is the basic block where all the
i[3210] insns are residing.  Except when we turn a conditional trap into
an unconditional one, we split the block during try_combine and then we can
have LOG_LINKS from the dead basic block after the unconditional trap to the
first part, so this_basic_block might not contain some or all of the
instructions anymore.  This patch fixes it by not trying to optimize
anything in dead basic blocks, we are going to remove them as unreachable
during cfg cleanup anyway.

Bootstrapped/regtested on x86_64-linux, i686-linux, powerpc64-linux (tested
with -m32/-m64), preapproved by Segher in the PR, committed to trunk.

2017-10-03  Jakub Jelinek  <jakub@redhat.com>

	PR target/82386
	* combine.c (combine_instructions): Don't combine in unreachable
	basic blocks.

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

--- gcc/combine.c.jj	2017-09-15 17:53:28.000000000 +0200
+++ gcc/combine.c	2017-10-02 16:04:13.652991681 +0200
@@ -1232,6 +1232,12 @@ combine_instructions (rtx_insn *f, unsig
   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;
--- gcc/testsuite/gcc.dg/pr82386.c.jj	2017-10-02 16:13:03.345490374 +0200
+++ gcc/testsuite/gcc.dg/pr82386.c	2017-10-02 16:12:20.000000000 +0200
@@ -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;
+        }
+    }
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]