vect: Use adjusted niters by considering peeling prologue

This patch is derived from the review of vector with length patch
series.  I relaxed the guard on LOOP_VINFO_PEELING_FOR_ALIGNMENT for
vector with length as Richard S.'s suggestion, then encountered one
failure from case gcc.dg/vect/vect-ifcvt-11.c with param
vect-partial-vector-usage=2 enablement run.  The root cause is that
we still use the original niters for the loop body vectorization,
it leads the access to go out of bound, instead we should use
LOOP_VINFO_NITERS which has been adjusted in vect_do_peeling by
considering the peeling number for prologue.

Bootstrapped/regtested on aarch64-linux-gnu and powerpc64le-linux-gnu.

gcc/ChangeLog:

	* tree-vect-loop.c (vect_transform_loop): Use LOOP_VINFO_NITERS which
	is adjusted by considering peeled prologue for non
	vect_use_loop_mask_for_alignment_p cases.
This commit is contained in:
Kewen Lin 2020-07-09 21:58:28 -05:00
parent 3f8ca9cb86
commit 08a94a95d1

View file

@ -8615,9 +8615,15 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple *loop_vectorized_call)
LOOP_VINFO_INT_NITERS (loop_vinfo) / lowest_vf);
step_vector = build_one_cst (TREE_TYPE (niters));
}
else
else if (vect_use_loop_mask_for_alignment_p (loop_vinfo))
vect_gen_vector_loop_niters (loop_vinfo, niters, &niters_vector,
&step_vector, niters_no_overflow);
else
/* vect_do_peeling subtracted the number of peeled prologue
iterations from LOOP_VINFO_NITERS. */
vect_gen_vector_loop_niters (loop_vinfo, LOOP_VINFO_NITERS (loop_vinfo),
&niters_vector, &step_vector,
niters_no_overflow);
}
/* 1) Make sure the loop header has exactly two entries