]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/92704 fix ifcvt ICE with loops without stores
authorRichard Biener <rguenther@suse.de>
Fri, 14 Feb 2020 08:14:42 +0000 (09:14 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 14 Feb 2020 10:01:49 +0000 (11:01 +0100)
2020-02-14  Richard Biener  <rguenther@suse.de>

Backport from mainline
2019-11-29  Richard Biener  <rguenther@suse.de>

PR tree-optimization/92704
* tree-if-conv.c (combine_blocks): Deal with virtual PHIs
in loops performing only loads.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr92704.c [new file with mode: 0644]
gcc/tree-if-conv.c

index 5e79258bfe8cba20a9e14ae081cb9f1ab7f7c0ae..bfed93eac8713412da83fc18b2b6917bb871440b 100644 (file)
@@ -1,3 +1,12 @@
+2020-02-14  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2019-11-29  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/92704
+       * tree-if-conv.c (combine_blocks): Deal with virtual PHIs
+       in loops performing only loads.
+
 2020-02-14  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
index 24e5e88d76328316cc1476990f9efd3ecc7fe51f..22660ff856e4c8e6b7e7b6e58944e2c57062b8ae 100644 (file)
@@ -1,3 +1,11 @@
+2020-02-14  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2019-11-29  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/92704
+       * gcc.dg/torture/pr92704.c: New testcase.
+
 2020-02-13  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/93576
diff --git a/gcc/testsuite/gcc.dg/torture/pr92704.c b/gcc/testsuite/gcc.dg/torture/pr92704.c
new file mode 100644 (file)
index 0000000..79994a3
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fexceptions -fnon-call-exceptions -fno-tree-dce -ftree-loop-if-convert" } */
+int zr, yx;
+
+void __attribute__ ((simd))
+oj (int rd, int q7)
+{
+  int wo = (__UINTPTR_TYPE__)&rd;
+
+  while (q7 < 1)
+    {
+      int kv;
+      short int v3;
+
+      for (v3 = 0; v3 < 82; v3 += 3)
+        {
+        }
+
+      kv = zr ? 0 : v3;
+      yx = kv < rd;
+      zr = zr && yx;
+      ++q7;
+    }
+}
index 98566e3fd194278f858b61d0dedfb0fbdf1b472b..2780a4b243fcd839da76f60d1b70faaa2c1ad771 100644 (file)
@@ -2626,6 +2626,11 @@ combine_blocks (struct loop *loop)
       vphi = get_virtual_phi (bb);
       if (vphi)
        {
+         /* When there's just loads inside the loop a stray virtual
+            PHI merging the uses can appear, update last_vdef from
+            it.  */
+         if (!last_vdef)
+           last_vdef = gimple_phi_arg_def (vphi, 0);
          imm_use_iterator iter;
          use_operand_p use_p;
          gimple *use_stmt;
@@ -2657,6 +2662,10 @@ combine_blocks (struct loop *loop)
              if (gimple_vdef (stmt))
                last_vdef = gimple_vdef (stmt);
            }
+         else
+           /* If this is the first load we arrive at update last_vdef
+              so we handle stray PHIs correctly.  */
+           last_vdef = gimple_vuse (stmt);
          if (predicated[i])
            {
              ssa_op_iter i;