]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/117594 - fix live op vectorization for length masked case
authorRichard Biener <rguenther@suse.de>
Mon, 18 Nov 2024 12:46:52 +0000 (13:46 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 18 Nov 2024 17:57:21 +0000 (18:57 +0100)
The code was passing factor == 0 to vect_get_loop_len which always
returns an unmodified length, even if the number of scalar elements
doesn't agree.  It also failed to insert the eventually generated
code.

PR tree-optimization/117594
* tree-vect-loop.cc (vectorizable_live_operation_1): Pass
factor == 1 to vect_get_loop_len, insert generated stmts.

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

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

diff --git a/gcc/testsuite/gcc.dg/vect/pr117594.c b/gcc/testsuite/gcc.dg/vect/pr117594.c
new file mode 100644 (file)
index 0000000..ab21390
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-require-effective-target int32plus } */
+
+#include "tree-vect.h"
+
+unsigned a;
+short b, d, e;
+int main()
+{
+  check_vect ();
+  short h = d;
+  short *z = &h;
+  for (_Bool i = 0; i < 1; i = 1)
+    for (unsigned j = 0; j < (z[i] ?: 10); j += 3)
+      {
+       a -= 9;
+       b -= ~e;
+      }
+  if (a != 4294967260)
+    __builtin_abort ();
+}
index 18c4fa1d000a9f06090c19e8ed36ad0ecbe5b1ac..ce728143469d8fcc16bb6480ec6ad623193bbe29 100644 (file)
@@ -11221,7 +11221,8 @@ vectorizable_live_operation_1 (loop_vec_info loop_vinfo,
       gimple_stmt_iterator gsi = gsi_last (tem);
       tree len = vect_get_loop_len (loop_vinfo, &gsi,
                                    &LOOP_VINFO_LENS (loop_vinfo),
-                                   1, vectype, 0, 0);
+                                   1, vectype, 0, 1);
+      gimple_seq_add_seq (&stmts, tem);
 
       /* BIAS - 1.  */
       signed char biasval = LOOP_VINFO_PARTIAL_LOAD_STORE_BIAS (loop_vinfo);