* [PATCH] tree-optimization/114733 - neg induction fails for 1 element vectors
@ 2024-04-16 10:36 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2024-04-16 10:36 UTC (permalink / raw)
To: gcc-patches
The neg induction vectorization code isn't prepared to deal with
single element vectors.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
Richard.
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 | 20 ++++++++++++++++++++
gcc/tree-vect-loop.cc | 2 ++
2 files changed, 22 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/vect/pr114733.c
diff --git a/gcc/testsuite/gcc.dg/vect/pr114733.c b/gcc/testsuite/gcc.dg/vect/pr114733.c
new file mode 100644
index 00000000000..219cbf20469
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr114733.c
@@ -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;
+}
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 025319e0cb1..431b3e9492c 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -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)
{
--
2.35.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-16 10:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-16 10:36 [PATCH] tree-optimization/114733 - neg induction fails for 1 element vectors Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).