The following removes an assert in the vectorizer since we can handle
this nested cycle just fine.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2019-02-22  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/89440
        * tree-vect-loop.c (vect_create_epilog_for_reduction): Remove
        not necessary assert.

        * gcc.dg/vect/pr89440.c: New testcase.

Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c        (revision 269096)
+++ gcc/tree-vect-loop.c        (working copy)
@@ -5494,13 +5494,6 @@ vect_finalize_reduction:
                = loop_vinfo->lookup_stmt (exit_phi);
               gphi *vect_phi;
 
-              /* FORNOW. Currently not supporting the case that an inner-loop
-                 reduction is not used in the outer-loop (but only outside the
-                 outer-loop), unless it is double reduction.  */
-              gcc_assert ((STMT_VINFO_RELEVANT_P (exit_phi_vinfo)
-                           && !STMT_VINFO_LIVE_P (exit_phi_vinfo))
-                          || double_reduc);
-
              if (double_reduc)
                STMT_VINFO_VEC_STMT (exit_phi_vinfo) = inner_phi;
              else
Index: gcc/testsuite/gcc.dg/vect/pr89440.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/pr89440.c (nonexistent)
+++ gcc/testsuite/gcc.dg/vect/pr89440.c (working copy)
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-additional-options "-ffast-math" } */
+
+#include "tree-vect.h"
+
+float __attribute__((noinline,noclone))
+f (float x)
+{
+  int i;
+  float j;
+  float a = 0;
+  for (i = 0; i < 4; ++i)
+    {
+      for (j = 0; j < 4; ++j)
+       {
+         a += 1;
+         x += a;
+       }
+    }
+  return x;
+}
+
+int
+main()
+{
+  check_vect ();
+  if (f (1.0f) != 137.0f)
+    abort ();
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump "OUTER LOOP VECTORIZED" "vect" { target 
vect_float } } } */

Reply via email to