re PR tree-optimization/56350 (ICE in vectorizable_reduction, at tree-vect-loop.c...
authorJakub Jelinek <jakub@redhat.com>
Tue, 19 Feb 2013 09:14:33 +0000 (10:14 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 19 Feb 2013 09:14:33 +0000 (10:14 +0100)
PR tree-optimization/56350
* tree-vect-loop.c (vectorizable_reduction): If orig_stmt, return false
if haven't found reduction or nested cycle operand, rather than
asserting we must find it.

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

From-SVN: r196134

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

index 884826439bdfdf4189968eb6c9f4123631e0048c..b4036f2a25c264c69a7edb2040d7fb72f6efab6f 100644 (file)
@@ -1,5 +1,10 @@
 2013-02-19  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/56350
+       * tree-vect-loop.c (vectorizable_reduction): If orig_stmt, return false
+       if haven't found reduction or nested cycle operand, rather than
+       asserting we must find it.
+
        PR tree-optimization/56381
        * tree-ssa-pre.c (create_expression_by_pieces): Fix up last argument
        to fold_build3.
index 1828629494cc5d30b55108c40046d1066cbcd160..94a237ba3650ef74dab1da0794a30a76ba96f6fe 100644 (file)
@@ -1,5 +1,8 @@
 2013-02-19  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/56350
+       * gcc.dg/pr56350.c: New test.
+
        PR tree-optimization/56381
        * g++.dg/opt/pr56381.C: New test.
 
diff --git a/gcc/testsuite/gcc.dg/pr56350.c b/gcc/testsuite/gcc.dg/pr56350.c
new file mode 100644 (file)
index 0000000..899a507
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR tree-optimization/56350 */
+/* { dg-do compile } */
+/* { dg-options "-O -ftree-vectorize" } */
+
+int a, b, c;
+
+void
+f (void)
+{
+  for (; c; c++)
+    for (b = 0; b < 2; b++)
+      a /= 8;
+}
index a2f90138fc9fc09b6df021e7793c8f6033ce3730..3693cd27a961a043003d2534950fed8617085842 100644 (file)
@@ -4707,7 +4707,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_iterator *gsi,
      The last use is the reduction variable.  In case of nested cycle this
      assumption is not true: we use reduc_index to record the index of the
      reduction variable.  */
-  for (i = 0; i < op_type-1; i++)
+  for (i = 0; i < op_type - 1; i++)
     {
       /* The condition of COND_EXPR is checked in vectorizable_condition().  */
       if (i == 0 && code == COND_EXPR)
@@ -4739,11 +4739,18 @@ vectorizable_reduction (gimple stmt, gimple_stmt_iterator *gsi,
   if (!vectype_in)
     vectype_in = tem;
   gcc_assert (is_simple_use);
-  gcc_assert (dt == vect_reduction_def
-              || dt == vect_nested_cycle
-              || ((dt == vect_internal_def || dt == vect_external_def
-                   || dt == vect_constant_def || dt == vect_induction_def)
-                   && nested_cycle && found_nested_cycle_def));
+  if (!(dt == vect_reduction_def
+       || dt == vect_nested_cycle
+       || ((dt == vect_internal_def || dt == vect_external_def
+            || dt == vect_constant_def || dt == vect_induction_def)
+           && nested_cycle && found_nested_cycle_def)))
+    {
+      /* For pattern recognized stmts, orig_stmt might be a reduction,
+        but some helper statements for the pattern might not, or
+        might be COND_EXPRs with reduction uses in the condition.  */
+      gcc_assert (orig_stmt);
+      return false;
+    }
   if (!found_nested_cycle_def)
     reduc_def_stmt = def_stmt;