[gcc r11-5048] tree-optimization/97835 - fix step vector construction for SLP induction

Richard Biener rguenth@gcc.gnu.org
Mon Nov 16 09:27:32 GMT 2020


https://gcc.gnu.org/g:d12603b746986554981f5ee220926a36a6cb6baf

commit r11-5048-gd12603b746986554981f5ee220926a36a6cb6baf
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Nov 16 09:06:41 2020 +0100

    tree-optimization/97835 - fix step vector construction for SLP induction
    
    We're stripping conversions off access functions of inductions and
    thus the step can be of different sign.  Fix bogus step CTORs by
    converting the elements rather than the whole vector.
    
    2020-11-16  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/97835
            * tree-vect-loop.c (vectorizable_induction): Convert step
            scalars rather than step vector.
    
            * gcc.dg/vect/pr97835.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/vect/pr97835.c | 21 +++++++++++++++++++++
 gcc/tree-vect-loop.c                |  2 +-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/vect/pr97835.c b/gcc/testsuite/gcc.dg/vect/pr97835.c
new file mode 100644
index 00000000000..5ca477bf806
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr97835.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+
+struct co {
+  int gx;
+  int ty;
+};
+
+void
+x0 (struct co *yy, long int kc, int wi, int md)
+{
+  while (wi < 1)
+    {
+      yy[wi].gx = md;
+      yy[wi].ty = wi;
+      md += kc;
+      ++wi;
+    }
+}
+
+/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 39b7319e825..4d5532f71d0 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -7999,6 +7999,7 @@ vectorizable_induction (loop_vec_info loop_vinfo,
 	    {
 	      /* The scalar steps of the IVs.  */
 	      tree elt = steps[(ivn*const_nunits + eltn) % group_size];
+	      elt = gimple_convert (&init_stmts, TREE_TYPE (step_vectype), elt);
 	      step_elts.quick_push (elt);
 	      if (!init_node)
 		{
@@ -8018,7 +8019,6 @@ vectorizable_induction (loop_vec_info loop_vinfo,
 				   : build_int_cstu (stept, mul_elt));
 	    }
 	  vec_step = gimple_build_vector (&init_stmts, &step_elts);
-	  vec_step = gimple_convert (&init_stmts, step_vectype, vec_step);
 	  vec_steps.safe_push (vec_step);
 	  tree step_mul = gimple_build_vector (&init_stmts, &mul_elts);
 	  if (peel_mul)


More information about the Gcc-cvs mailing list