From: Kewen Lin Date: Fri, 10 Jul 2020 02:58:28 +0000 (-0500) Subject: vect: Use adjusted niters by considering peeling prologue X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=08a94a95d10f311d2a83e6f4c076babd8afd6a3e;p=gcc.git 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. --- diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 6ec16475c66..0a9be35ddec 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -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