Richard Biener <richard.guent...@gmail.com> writes: > On Tue, Oct 8, 2024 at 10:36 AM liuhongt <hongtao....@intel.com> wrote: >> >> >So should we adjust very-cheap to allow niter peeling as proposed or >> >should we switch the default at -O2 to cheap? >> I prefer the former. >> >> Update in V2: >> Adjust testcase after relax O2 vectorization. >> >> Ok for trunk? > > OK.
We'd also need to update the documentation: ... The @samp{very-cheap} model only allows vectorization if the vector code would entirely replace the scalar code that is being vectorized. For example, if each iteration of a vectorized loop would only be able to handle exactly four iterations of the scalar loop, the @samp{very-cheap} model would only allow vectorization if the scalar iteration count is known to be a multiple of four. And since it's a change in documented behaviour, it should probably be in the release notes too. Thanks, Richard > > Thanks, > Richard. > >> gcc/ChangeLog: >> >> * tree-vect-loop.cc (vect_analyze_loop_costing): Enable >> vectorization for LOOP_VINFO_PEELING_FOR_NITER in very cheap >> cost model. >> (vect_analyze_loop): Disable epilogue vectorization in very >> cheap cost model. >> --- >> gcc/tree-vect-loop.cc | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc >> index 242d5e2d916..06afd8cae79 100644 >> --- a/gcc/tree-vect-loop.cc >> +++ b/gcc/tree-vect-loop.cc >> @@ -2356,8 +2356,7 @@ vect_analyze_loop_costing (loop_vec_info loop_vinfo, >> a copy of the scalar code (even if we might be able to vectorize it). >> */ >> if (loop_cost_model (loop) == VECT_COST_MODEL_VERY_CHEAP >> && (LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) >> - || LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo) >> - || LOOP_VINFO_PEELING_FOR_NITER (loop_vinfo))) >> + || LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo))) >> { >> if (dump_enabled_p ()) >> dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, >> @@ -3638,7 +3637,8 @@ vect_analyze_loop (class loop *loop, vec_info_shared >> *shared) >> /* No code motion support for multiple epilogues >> so for now >> not supported when multiple exits. */ >> && !LOOP_VINFO_EARLY_BREAKS (first_loop_vinfo) >> - && !loop->simduid); >> + && !loop->simduid >> + && loop_cost_model (loop) > >> VECT_COST_MODEL_VERY_CHEAP); >> if (!vect_epilogues) >> return first_loop_vinfo; >> >> -- >> 2.31.1 >>