[PATCH] Fix PR92555

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Fix PR92555

Richard Biener

Not sure how we got away with not doing this, the following scans
PHIs to look for non-SLP stmts.

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

Richard.

2019-09-19  Richard Biener  <[hidden email]>

        PR tree-optimization/92555
        * tree-vect-loop.c (vect_update_vf_for_slp): Also scan PHIs
        for non-SLP stmts.

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

Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c (revision 278405)
+++ gcc/tree-vect-loop.c (working copy)
@@ -1398,6 +1398,18 @@ vect_update_vf_for_slp (loop_vec_info lo
   for (i = 0; i < nbbs; i++)
     {
       basic_block bb = bbs[i];
+      for (gphi_iterator si = gsi_start_phis (bb); !gsi_end_p (si);
+   gsi_next (&si))
+ {
+  stmt_vec_info stmt_info = loop_vinfo->lookup_stmt (si.phi ());
+  if (!stmt_info)
+    continue;
+  if ((STMT_VINFO_RELEVANT_P (stmt_info)
+       || VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE (stmt_info)))
+      && !PURE_SLP_STMT (stmt_info))
+    /* STMT needs both SLP and loop-based vectorization.  */
+    only_slp_in_loop = false;
+ }
       for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si);
    gsi_next (&si))
  {
Index: gcc/testsuite/gcc.dg/vect/pr92555.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/pr92555.c (nonexistent)
+++ gcc/testsuite/gcc.dg/vect/pr92555.c (working copy)
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fwrapv" } */
+
+signed char rq;
+
+signed char
+pu (int tr, int al)
+{
+  signed char x8;
+
+  while (tr != 0)
+    {
+      for (x8 = 0; x8 >= 0; x8 += 2)
+        ;
+
+      rq ^= al ^ 1;
+      ++x8;
+      ++tr;
+    }
+
+  return x8;
+}