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

Ira Rosen IRAR@il.ibm.com
Thu Sep 4 12:01:00 GMT 2008


Hi,

(Here is the previous discussion:
http://gcc.gnu.org/ml/gcc-patches/2008-07/msg01254.html).

The testcase in PR36630 ICEs, since evolution_part_in_loop_num returns NULL
for the access function (short int) {(short unsigned int) i_44, +, 1}_1).
However, as Zdenek explained, using STRIP_NOPS in
evolution_part_in_loop_num is incorrect.

As suggested by Richard in bugzilla, this patch adds STRIP_NOPS in the
transformation phase of the vectorizer, based on the fact that we analyzed
the access function of the original loop properly.

Bootstrapped and tested on x86_64-linux. O.K. for 4.3 branch?

This loop is not vectorizable anymore with 4.4 because of unknown number of
iterations (and, therefore, there is no ICE). So, I am not sure if this
patch should be applied to 4.4 as well, since maybe now such scenario is
impossible...

Thanks,
Ira

ChangeLog:

      PR tree-optimization/36630
      * tree-vect-transform.c (vect_update_ivs_after_vectorizer):
      Call STRIP_NOPS before calling evolution_part_in_loop_num.

testsuite/ChangeLog:

      PR tree-optimization/36630
      * gcc.dg/vect/pr36630.c: New test.


Index: tree-vect-transform.c
===================================================================
--- tree-vect-transform.c       (revision 139930)
+++ tree-vect-transform.c       (working copy)
@@ -6529,6 +6529,7 @@ vect_update_ivs_after_vectorizer (loop_v

       access_fn = analyze_scalar_evolution (loop, PHI_RESULT (phi));
       gcc_assert (access_fn);
+      STRIP_NOPS (access_fn);
       evolution_part =
         unshare_expr (evolution_part_in_loop_num (access_fn, loop->num));
       gcc_assert (evolution_part != NULL_TREE);

Index: testsuite/gcc.dg/vect/pr36630.c
===================================================================>
--- testsuite/gcc.dg/vect/pr36630.c     (revision 0)
+++ testsuite/gcc.dg/vect/pr36630.c     (revision 0)
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+
+void
+foo (unsigned char *x, short y)
+{
+  short i;
+
+  i = 2;
+  while (i < y)
+    {
+      x[i - 1] = x[i];
+      i = i + 1;
+    }
+}
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */



More information about the Gcc-patches mailing list