]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end: rejects loops with nonlinear inductions and early breaks [PR113163]
authorTamar Christina <tamar.christina@arm.com>
Tue, 9 Jan 2024 11:16:16 +0000 (11:16 +0000)
committerTamar Christina <tamar.christina@arm.com>
Tue, 9 Jan 2024 11:16:16 +0000 (11:16 +0000)
We can't support nonlinear inductions other than neg when vectorizing
early breaks and iteration count is known.

For early break we currently require a peeled epilog but in these cases
we can't compute the remaining values.

gcc/ChangeLog:

PR middle-end/113163
* tree-vect-loop-manip.cc (vect_can_peel_nonlinear_iv_p):
Reject non-linear inductions that aren't supported.

gcc/testsuite/ChangeLog:

PR middle-end/113163
* gcc.target/gcn/pr113163.c: New test.

gcc/testsuite/gcc.target/gcn/pr113163.c [new file with mode: 0644]
gcc/tree-vect-loop-manip.cc

diff --git a/gcc/testsuite/gcc.target/gcn/pr113163.c b/gcc/testsuite/gcc.target/gcn/pr113163.c
new file mode 100644 (file)
index 0000000..99b0fdb
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O2 -ftree-vectorize" } */ 
+
+struct _reent { union { struct { char _l64a_buf[8]; } _reent; } _new; };
+static const char R64_ARRAY[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+char *
+_l64a_r (struct _reent *rptr,
+     long value)
+{
+  char *ptr;
+  char *result;
+  int i, index;
+  unsigned long tmp = (unsigned long)value & 0xffffffff;
+  result = 
+          ((
+          rptr
+          )->_new._reent._l64a_buf)
+                               ;
+  ptr = result;
+  for (i = 0; i < 6; ++i)
+    {
+      if (tmp == 0)
+ {
+   *ptr = '\0';
+   break;
+ }
+      *ptr++ = R64_ARRAY[index];
+      tmp >>= 6;
+    }
+}
index 927f76a09471e28167114ae728df5b02a111d843..2313d26338d6f08426ebd1f5033526f3901ba473 100644 (file)
@@ -2063,6 +2063,25 @@ vect_can_peel_nonlinear_iv_p (loop_vec_info loop_vinfo,
       return false;
     }
 
+  /* We can't support partial vectors and early breaks with an induction
+     type other than add or neg since we require the epilog and can't
+     perform the peeling.  The below condition mirrors that of
+     vect_gen_vector_loop_niters  where niters_vector_mult_vf_var then sets
+     step_vector to VF rather than 1.  This is what creates the nonlinear
+     IV.  PR113163.  */
+  if (LOOP_VINFO_EARLY_BREAKS (loop_vinfo)
+      && LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant ()
+      && LOOP_VINFO_USING_PARTIAL_VECTORS_P (loop_vinfo)
+      && induction_type != vect_step_op_neg)
+    {
+      if (dump_enabled_p ())
+       dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                        "Peeling for epilogue is not supported"
+                        " for nonlinear induction except neg"
+                        " when VF is known and early breaks.\n");
+      return false;
+    }
+
   return true;
 }