re PR tree-optimization/78574 (ice on valid C code at -O2 and -O3 in both 32- and...
authorBin Cheng <bin.cheng@arm.com>
Wed, 30 Nov 2016 14:41:09 +0000 (14:41 +0000)
committerBin Cheng <amker@gcc.gnu.org>
Wed, 30 Nov 2016 14:41:09 +0000 (14:41 +0000)
PR tree-optimization/78574
* tree-ssa-loop-ivopts.c (find_deriving_biv_for_expr): Skip loop
header PHI that doesn't define biv.
gcc/testsuite
PR tree-optimization/78574
* gcc.c-torture/compile/pr78574.c: New test.

From-SVN: r243026

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr78574.c [new file with mode: 0644]
gcc/tree-ssa-loop-ivopts.c

index ac65b1cf80d4956344c2d32333b4ac7381bfae7b..0fc87d259a86a2359a998cb8d24e3bf6965dc697 100644 (file)
@@ -1,3 +1,9 @@
+2016-11-30  Bin Cheng  <bin.cheng@arm.com>
+
+       PR tree-optimization/78574
+       * tree-ssa-loop-ivopts.c (find_deriving_biv_for_expr): Skip loop
+       header PHI that doesn't define biv.
+
 2016-11-30  Jakub Jelinek  <jakub@redhat.com>
 
        * emit-rtl.c (verify_insn_sharing): Call verify_rtx_sharing instead of
index 5aff606fa0ecc94d76cc04dbe43a41dfea0103d1..eac361b5f85732e47cf86a9c1d778f4848f185e8 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-30  Bin Cheng  <bin.cheng@arm.com>
+
+       PR tree-optimization/78574
+       * gcc.c-torture/compile/pr78574.c: New test.
+
 2016-11-30  Andre Vehreschild  <vehre@gcc.gnu.org>
 
        * caf/single.c (_gfortran_caf_is_present): Prevent fallthrough
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr78574.c b/gcc/testsuite/gcc.c-torture/compile/pr78574.c
new file mode 100644 (file)
index 0000000..8c91d1e
--- /dev/null
@@ -0,0 +1,27 @@
+/* PR tree-optimization/78574 */
+
+int a, d, f, g;
+int b[1];
+short h;
+int main() {
+  long j;
+  int k, i;
+  for (; j; j++) {
+    i = 0;
+    for (; i < 6; i++) {
+      int l = a, m = d || g;
+    L:
+      l ^ m | a;
+    }
+    b[j + 1] = 2;
+    ++k;
+    for (; g; g++) {
+      d ^= h;
+      if (f)
+        for (;;)
+          ;
+    }
+  }
+  if (k)
+    goto L;
+}
index 5c667a201a78f6b1e7eaaaef3029b21135bf6ceb..00b287abf1a138e838f8dce06d1978da710e5494 100644 (file)
@@ -1853,6 +1853,11 @@ find_deriving_biv_for_expr (struct ivopts_data *data, tree expr)
     {
       ssa_op_iter iter;
       use_operand_p use_p;
+      basic_block phi_bb = gimple_bb (phi);
+
+      /* Skip loop header PHI that doesn't define biv.  */
+      if (phi_bb->loop_father == data->current_loop)
+       return NULL;
 
       if (virtual_operand_p (gimple_phi_result (phi)))
        return NULL;