]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/114733 - neg induction fails for 1 element vectors
authorRichard Biener <rguenther@suse.de>
Tue, 16 Apr 2024 08:46:03 +0000 (10:46 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 16 Apr 2024 10:37:04 +0000 (12:37 +0200)
The neg induction vectorization code isn't prepared to deal with
single element vectors.

PR tree-optimization/114733
* tree-vect-loop.cc (vectorizable_nonlinear_induction): Reject
neg induction vectorization of single element vectors.

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

gcc/testsuite/gcc.dg/vect/pr114733.c [new file with mode: 0644]
gcc/tree-vect-loop.cc

diff --git a/gcc/testsuite/gcc.dg/vect/pr114733.c b/gcc/testsuite/gcc.dg/vect/pr114733.c
new file mode 100644 (file)
index 0000000..219cbf2
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-additional-options "-O3" } */
+
+#include "tree-vect.h"
+
+long b = 1;
+signed char c;
+int d[25];
+
+int main()
+{
+  check_vect ();
+  for (signed char g = 0; g < 8; g += 1)
+    for (short h = 0; h < 25; h += 2) {
+      b *= -1;
+      c ^= d[h];
+    }
+  if (b != 1)
+    abort ();
+  return 0;
+}
index 025319e0cb12265c483d06536cbcb6404e71cc70..431b3e9492c0362ca48032a0172a8aa467983ef7 100644 (file)
@@ -9685,6 +9685,8 @@ vectorizable_nonlinear_induction (loop_vec_info loop_vinfo,
   switch (induction_type)
     {
     case vect_step_op_neg:
+      if (maybe_eq (TYPE_VECTOR_SUBPARTS (vectype), 1u))
+       return false;
       if (TREE_CODE (init_expr) != INTEGER_CST
          && TREE_CODE (init_expr) != REAL_CST)
        {