tree-optimization/117594 - fix live op vectorization for length masked case

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.
This commit is contained in:
Richard Biener 2024-11-18 13:46:52 +01:00 committed by Richard Biener
parent f5ceca9627
commit c108785c42
2 changed files with 22 additions and 1 deletions

View File

@ -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 ();
}

View 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);