]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR tree-optimization/56350 (ICE in vectorizable_reduction, at tree-vect...
authorJakub Jelinek <jakub@redhat.com>
Tue, 19 Feb 2013 17:30:27 +0000 (18:30 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 19 Feb 2013 17:30:27 +0000 (18:30 +0100)
Backported from mainline
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.

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

From-SVN: r196150

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

index a072bff8a27d850b251bf3508634619387500ba5..a2555c0108cd6f8e694f4eb62bbbcb89effa3e68 100644 (file)
@@ -3,6 +3,11 @@
        Backported from mainline
        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 a8a2fe3a76b6e9b24d0b1103f73b5cf325679bd6..e12c918e867dae84a34c4b2624f4d1260749a9a4 100644 (file)
@@ -1,6 +1,11 @@
 2013-02-19  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2013-02-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/56350
+       * gcc.dg/pr56350.c: New test.
+
        2013-02-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/56250
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 5e7fb6692528c9e450ce7fc1fdfda0b6540a1c44..b6f85d8e19c72b98fd5e24930108312ca7293e28 100644 (file)
@@ -4522,7 +4522,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)
@@ -4554,11 +4554,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;