]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/53408 (ICE in get_initial_def_for_induction, at tree-vect-loop.c...
authorRichard Guenther <rguenther@suse.de>
Mon, 21 May 2012 12:45:59 +0000 (12:45 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 21 May 2012 12:45:59 +0000 (12:45 +0000)
2012-05-21  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/53408
* tree-vect-loop.c (vectorizable_induction): Properly check
the restriction that we cannot handle induction results from
the inner loop outside of the outer loop.

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

From-SVN: r187710

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr53408.c [new file with mode: 0644]
gcc/tree-vect-loop.c

index 3634b63a951119eebc37c8c48ec59be6d05b33fc..75190eb106ef5cfdc8f7fa06508e05ff4b9df207 100644 (file)
@@ -1,3 +1,10 @@
+2012-05-21  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/53408
+       * tree-vect-loop.c (vectorizable_induction): Properly check
+       the restriction that we cannot handle induction results from
+       the inner loop outside of the outer loop.
+
 2012-05-21  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/53416
index 3c82445eea2d395a2ed91e2be8719b4c4dce6db7..585ee31ff9357104f158b26674ffccd6f4f8e584 100644 (file)
@@ -1,3 +1,8 @@
+2012-05-21  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/53408
+       * gcc.dg/torture/pr53408.c: New testcase.
+
 2012-05-21  Uros Bizjak  <ubizjak@gmail.com>
            H.J. Lu  <hongjiu.lu@intel.com>
 
diff --git a/gcc/testsuite/gcc.dg/torture/pr53408.c b/gcc/testsuite/gcc.dg/torture/pr53408.c
new file mode 100644 (file)
index 0000000..25c6dc7
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+
+int a, b, c, d, e;
+void
+fn1 ()
+{
+  int f, g;
+  char h = 0;
+  b = 0;
+  for (; b < 32; b++)
+    {
+      g = h > e ? h : h << 1;
+      f = g && a ? 0 : 1;
+      h = 1;
+      for (; h > 0; h = h + 1)
+       c = 0 < h | f;
+    }
+  if (h)
+    d = 0;
+}
index 5fe1165917e8dcad11860717591fab9f4329986b..528788fee13c52fe4aff0ddd10180c3c52ec24ee 100644 (file)
@@ -5061,12 +5061,46 @@ vectorizable_induction (gimple phi, gimple_stmt_iterator *gsi ATTRIBUTE_UNUSED,
   tree vec_def;
 
   gcc_assert (ncopies >= 1);
-  /* FORNOW. This restriction should be relaxed.  */
-  if (nested_in_vect_loop_p (loop, phi) && ncopies > 1)
+  /* FORNOW. These restrictions should be relaxed.  */
+  if (nested_in_vect_loop_p (loop, phi))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "multiple types in nested loop.");
-      return false;
+      imm_use_iterator imm_iter;
+      use_operand_p use_p;
+      gimple exit_phi;
+      edge latch_e;
+      tree loop_arg;
+
+      if (ncopies > 1)
+       {
+         if (vect_print_dump_info (REPORT_DETAILS))
+           fprintf (vect_dump, "multiple types in nested loop.");
+         return false;
+       }
+
+      exit_phi = NULL;
+      latch_e = loop_latch_edge (loop->inner);
+      loop_arg = PHI_ARG_DEF_FROM_EDGE (phi, latch_e);
+      FOR_EACH_IMM_USE_FAST (use_p, imm_iter, loop_arg)
+       {
+         if (!flow_bb_inside_loop_p (loop->inner,
+                                     gimple_bb (USE_STMT (use_p))))
+           {
+             exit_phi = USE_STMT (use_p);
+             break;
+           }
+       }
+      if (exit_phi)
+       {
+         stmt_vec_info exit_phi_vinfo  = vinfo_for_stmt (exit_phi);
+         if (!(STMT_VINFO_RELEVANT_P (exit_phi_vinfo)
+               && !STMT_VINFO_LIVE_P (exit_phi_vinfo)))
+           {
+             if (vect_print_dump_info (REPORT_DETAILS))
+               fprintf (vect_dump, "inner-loop induction only used outside "
+                        "of the outer vectorized loop.");
+             return false;
+           }
+       }
     }
 
   if (!STMT_VINFO_RELEVANT_P (stmt_info))