This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, vectorizer] Fix PR tree-optimization/39675


Hi,

This patch fixes a bug in scheduling statements for vectorization. There
are currently two types of vectorization: loop-based vectorization and
loop-aware SLP. Scalar statement can be a part of SLP group and also be
used outside of SLP, and, therefore, such statement needs to be vectorized
in both ways (ideally, the SLP version can be reused, but this is not
supported for now). The bug was in decision whether to apply loop-based
vectorization for statements that are vectorized using SLP.

4.4 branch: bootstrapped with vectorization enabled and tested on
powerpc64-suse-linux. Committed revision 146365.
4.5: bootstrapped with vectorization enabled and will be tested on
powerpc64-suse-linux. I'll commit the patch after testing.

Ira:

4.4 ChangeLog:

      PR tree-optimization/39675
      * tree-vect-transform.c (vect_transform_loop): Remove currently
      redundant check of the return code of vect_schedule_slp. Check that
      stmt_vec_info still exists for the statement, before checking its
      vectorization type.

testsuite/ChangeLog:

      PR tree-optimization/39675
      * gcc.dg/vect/O3-pr39675-1.c: New test.


Index: tree-vect-transform.c
===================================================================
--- tree-vect-transform.c       (revision 146147)
+++ tree-vect-transform.c       (working copy)
@@ -8459,20 +8459,11 @@ vect_transform_loop (loop_vec_info loop_
                  if (vect_print_dump_info (REPORT_DETAILS))
                    fprintf (vect_dump, "=== scheduling SLP instances
===");

-                 is_store = vect_schedule_slp (loop_vinfo);
-
-                 /* IS_STORE is true if STMT is a store. Stores cannot be
of
-                    hybrid SLP type. They are removed in
-                    vect_schedule_slp_instance and their vinfo is
destroyed. */
-                 if (is_store)
-                   {
-                     gsi_next (&si);
-                     continue;
-                   }
-               }
+                 vect_schedule_slp (loop_vinfo);
+                }

              /* Hybrid SLP stmts must be vectorized in addition to SLP.
*/.
-             if (PURE_SLP_STMT (stmt_info))
+             if (!vinfo_for_stmt (stmt) || PURE_SLP_STMT (stmt_info))
                {
                  gsi_next (&si);
                  continue;
Index: testsuite/gcc.dg/vect/O3-pr39675-1.c
===================================================================
--- testsuite/gcc.dg/vect/O3-pr39675-1.c   (revision 0)
+++ testsuite/gcc.dg/vect/O3-pr39675-1.c   (revision 0)
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+
+typedef struct {
+    float vertexAttrib[16][4];
+    float vertexAttribPre[16][4];
+    float rasterAttrib[16][4];
+    float rasterAttribPre[16][4];
+} CRCurrentState;
+}
+void crStateCurrentInit(CRCurrentState *c)
+{
+  unsigned int i;
+  for (i = 0; i < 16; i++)
+    {
+      (c->vertexAttribPre[i])[0] = (c->vertexAttrib[i])[0];
+      (c->vertexAttribPre[i])[1] = (c->vertexAttrib[i])[1];
+      (c->vertexAttribPre[i])[2] = (c->vertexAttrib[i])[2];
+      (c->vertexAttribPre[i])[3] = (c->vertexAttrib[i])[3];
+      (c->rasterAttrib[i])[0] = (c->vertexAttrib[i])[0];
+      (c->rasterAttrib[i])[1] = (c->vertexAttrib[i])[1];
+      (c->rasterAttrib[i])[2] = (c->vertexAttrib[i])[2];
+      (c->rasterAttrib[i])[3] = (c->vertexAttrib[i])[3];
+      (c->rasterAttribPre[i])[0] = (c->vertexAttrib[i])[0];
+      (c->rasterAttribPre[i])[1] = (c->vertexAttrib[i])[1];
+      (c->rasterAttribPre[i])[2] = (c->vertexAttrib[i])[2];
+      (c->rasterAttribPre[i])[3] = (c->vertexAttrib[i])[3];
+    }
+}
+}
+/* { dg-final { cleanup-tree-dump "vect" } } */
+


4.5 ChangeLog:

      PR tree-optimization/39675
      * tree-vect-loop.c (vect_transform_loop): Remove currently redundant
      check of the return code of vect_schedule_slp. Check that
stmt_vec_info
      still exists for the statement, before checking its vectorization
type.

testsuite/ChangeLog:

      PR tree-optimization/39675
      * gcc.dg/vect/O3-pr39675-2.c: New test.

Index: tree-vect-loop.c
===================================================================
--- tree-vect-loop.c    (revision 146146)
+++ tree-vect-loop.c    (working copy)
@@ -3528,20 +3528,11 @@ vect_transform_loop (loop_vec_info loop_
                  if (vect_print_dump_info (REPORT_DETAILS))
                    fprintf (vect_dump, "=== scheduling SLP instances
===");.

-                 is_store = vect_schedule_slp (loop_vinfo);
-
-                 /* IS_STORE is true if STMT is a store. Stores cannot be
of
-                    hybrid SLP type. They are removed in
-                    vect_schedule_slp_instance and their vinfo is
destroyed. */
-                 if (is_store)
-                   {
-                     gsi_next (&si);
-                     continue;
-                   }
+                 vect_schedule_slp (loop_vinfo);
                }

              /* Hybrid SLP stmts must be vectorized in addition to SLP.
*/.
-             if (PURE_SLP_STMT (stmt_info))
+             if (!vinfo_for_stmt (stmt) || PURE_SLP_STMT (stmt_info))
                {
                  gsi_next (&si);
                  continue;
Index: testsuite/gcc.dg/vect/O3-pr39675-2.c
===================================================================
--- testsuite/gcc.dg/vect/O3-pr39675-2.c        (revision 0)
+++ testsuite/gcc.dg/vect/O3-pr39675-2.c        (revision 0)
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+
+#define N 128
+
+int out[N*4], out2[N], in[N*4];
+
+void
+foo ()
+{
+  int i, a0, a1, a2, a3;
+
+  for (i = 0; i < N; i++)
+    {
+      a0 = in[i*4];;
+      a1 = in[i*4 + 1];
+      a2 = in[i*4 + 2];
+      a3 = in[i*4 + 3];
+
+      out[i*4] = a0;
+      out[i*4 + 1] = a1;)
+      out[i*4 + 2] = a2;)
+      out[i*4 + 3] = a3;)
+
+      out2[i] = a0;
+    }
+}
+}
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1
"vect"  { target vect_strided_wide } } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1
"vect" { target vect_strided_wide } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]