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.
--- /dev/null
+/* { 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 ();
+}
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);