re PR tree-optimization/56787 (Vectorization fails because of CLOBBER statements)
authorRichard Biener <rguenther@suse.de>
Tue, 28 May 2013 13:36:25 +0000 (13:36 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 28 May 2013 13:36:25 +0000 (13:36 +0000)
2013-05-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/56787
* tree-vect-data-refs.c (vect_analyze_data_refs): Drop clobbers
from the list of data references.
* tree-vect-loop.c (vect_determine_vectorization_factor): Skip
clobbers.
(vect_analyze_loop_operations): Likewise.
(vect_transform_loop): Remove clobbers.

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

From-SVN: r199380

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

index 6dbdf3297ac667f5e24724d09086332da188855b..9f4f85e2fcb43fa3658f7f66498ca07a06264e34 100644 (file)
@@ -1,3 +1,13 @@
+2013-05-28  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/56787
+       * tree-vect-data-refs.c (vect_analyze_data_refs): Drop clobbers
+       from the list of data references.
+       * tree-vect-loop.c (vect_determine_vectorization_factor): Skip
+       clobbers.
+       (vect_analyze_loop_operations): Likewise.
+       (vect_transform_loop): Remove clobbers.
+
 2013-05-28  Martin Jambor  <mjambor@suse.cz>
 
        * tree-cfg.c (verify_expr): Verify that BIT_FIELD_REFs, IMAGPART_EXPRs
index 7e70dce0cdd48ea456292e0c6547825b88ffb687..28c6a6da236959fe7f0407f13d13356724dbe4b8 100644 (file)
@@ -1,3 +1,8 @@
+2013-05-28  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/56787
+       * gcc.dg/vect/pr56787.c: New testcase.
+
 2013-05-28  Janus Weil  <janus@gcc.gnu.org>
            Tobias Burnus  <burnus@net-b.de>
 
diff --git a/gcc/testsuite/gcc.dg/vect/pr56787.c b/gcc/testsuite/gcc.dg/vect/pr56787.c
new file mode 100644 (file)
index 0000000..313d477
--- /dev/null
@@ -0,0 +1,35 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_float } */
+
+inline void
+bar (const float s[5], float z[3][5])
+{
+  float a = s[0], b = s[1], c = s[2], d = s[3], e = s[4];
+  float f = 1.0f / a;
+  float u = f * b, v = f * c, w = f * d;
+  float p = 0.4f * (e - 0.5f * (b * u + c * v + d * w));
+  z[0][3] = b * w;
+  z[1][3] = c * w;
+  z[2][3] = d * w + p;
+}
+
+void
+foo (unsigned long n, const float *__restrict u0,
+     const float *__restrict u1, const float *__restrict u2,
+     const float *__restrict u3, const float *__restrict u4,
+     const float *__restrict s0, const float *__restrict s1,
+     const float *__restrict s2, float *__restrict t3,
+     float *__restrict t4)
+{
+  unsigned long i;
+  for (i = 0; i < n; i++)
+    {
+      float u[5], f[3][5];
+      u[0] = u0[i]; u[1] = u1[i]; u[2] = u2[i]; u[3] = u3[i]; u[4] = u4[i];
+      bar (u, f);
+      t3[i] = s0[i] * f[0][3] + s1[i] * f[1][3] + s2[i] * f[2][3];
+    }
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
index c26d25dabbbcf2b39aaa813a68ab66ca2167ae09..47ecad3528dc1cbff2becd0e4dd079e513590836 100644 (file)
@@ -2861,6 +2861,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
       bool gather = false;
       int vf;
 
+again:
       if (!dr || !DR_REF (dr))
         {
           if (dump_enabled_p ())
@@ -2872,6 +2873,19 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
       stmt = DR_STMT (dr);
       stmt_info = vinfo_for_stmt (stmt);
 
+      /* Discard clobbers from the dataref vector.  We will remove
+         clobber stmts during vectorization.  */
+      if (gimple_clobber_p (stmt))
+       {
+         if (i == datarefs.length () - 1)
+           {
+             datarefs.pop ();
+             break;
+           }
+         datarefs[i] = datarefs.pop ();
+         goto again;
+       }
+
       /* Check that analysis of the data-ref succeeded.  */
       if (!DR_BASE_ADDRESS (dr) || !DR_OFFSET (dr) || !DR_INIT (dr)
          || !DR_STEP (dr))
index 058e4a4ec547e8b3b1ff2504add1f7bfef51c397..d3281e4e51b97d4bb1b157c61ef0b87fbdb90851 100644 (file)
@@ -270,8 +270,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
          gcc_assert (stmt_info);
 
          /* Skip stmts which do not need to be vectorized.  */
-         if (!STMT_VINFO_RELEVANT_P (stmt_info)
-             && !STMT_VINFO_LIVE_P (stmt_info))
+         if ((!STMT_VINFO_RELEVANT_P (stmt_info)
+              && !STMT_VINFO_LIVE_P (stmt_info))
+             || gimple_clobber_p (stmt))
             {
               if (STMT_VINFO_IN_PATTERN_P (stmt_info)
                   && (pattern_stmt = STMT_VINFO_RELATED_STMT (stmt_info))
@@ -1431,7 +1432,8 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo, bool slp)
       for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
         {
           gimple stmt = gsi_stmt (si);
-         if (!vect_analyze_stmt (stmt, &need_to_vectorize, NULL))
+         if (!gimple_clobber_p (stmt)
+             && !vect_analyze_stmt (stmt, &need_to_vectorize, NULL))
            return false;
         }
     } /* bbs */
@@ -5595,7 +5597,17 @@ vect_transform_loop (loop_vec_info loop_vinfo)
           if (transform_pattern_stmt)
            stmt = pattern_stmt;
           else
-            stmt = gsi_stmt (si);
+           {
+             stmt = gsi_stmt (si);
+             /* During vectorization remove existing clobber stmts.  */
+             if (gimple_clobber_p (stmt))
+               {
+                 unlink_stmt_vdef (stmt);
+                 gsi_remove (&si, true);
+                 release_defs (stmt);
+                 continue;
+               }
+           }
 
          if (dump_enabled_p ())
            {