On Fri, 15 Nov 2024, Richard Biener wrote: > On Fri, 15 Nov 2024, Richard Sandiford wrote: > > > Richard Biener <rguent...@suse.de> writes: > > > The following ensures that peeling a single iteration for gaps is > > > sufficient by enforcing niter masking (partial vector use) given > > > we cannot (always) statically decide when the vector size isn't known. > > > The condition guarding this and thus statically giving a pass in > > > some cases for VL vectors is questionable, the patch doesn't address > > > this. > > > > > > This fixes a set of known failout from enabling > > > --param vect-force-slp=1 by default. > > > > > > Bootstrapped and tested on x86_64-unknown-linux-gnu. > > > > > > PR tree-optimization/117558 > > > * tree-vectorizer.h (_loop_vec_info::must_use_partial_vectors_p): New. > > > (LOOP_VINFO_MUST_USE_PARTIAL_VECTORS_P): Likewise. > > > * tree-vect-loop.cc (_loop_vec_info::_loop_vec_info): Initialize > > > must_use_partial_vectors_p. > > > (vect_determine_partial_vectors_and_peeling): Enforce it. > > > (vect_analyze_loop_2): Reset before restarting. > > > * tree-vect-stmts.cc (get_group_load_store_type): When peeling > > > a single gap iteration cannot be determined safe statically > > > enforce the use of partial vectors. > > > > LGTM. Just to make sure I understand... > > > > > --- > > > gcc/tree-vect-loop.cc | 13 ++++++++++++- > > > gcc/tree-vect-stmts.cc | 24 +++++++++++++++++++----- > > > gcc/tree-vectorizer.h | 4 ++++ > > > 3 files changed, 35 insertions(+), 6 deletions(-) > > >
[...] > > > + /* Records whether we must use niter masking for correctness reasons. > > > */ > > > + bool must_use_partial_vectors_p; > > > + > > > /* True if we've decided to use partially-populated vectors, so that > > > the vector loop can handle fewer than VF scalars. */ > > > bool using_partial_vectors_p; > > > @@ -1051,6 +1054,7 @@ public: > > > #define LOOP_VINFO_VERSIONING_THRESHOLD(L) (L)->versioning_threshold > > > #define LOOP_VINFO_VECTORIZABLE_P(L) (L)->vectorizable > > > #define LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P(L) > > > (L)->can_use_partial_vectors_p > > > +#define LOOP_VINFO_MUST_USE_PARTIAL_VECTORS_P(L) > > > (L)->can_use_partial_vectors_p [...] *sigh*, re-testing, re-posting for CI. You never learn that cut&paste is going to come back to you... Richard.