On Mon, Mar 22, 2021 at 09:22:26AM +0100, Richard Biener via Gcc wrote: > Better than doing loop versioning is to enhance SCEV (and thus also > dependence analysis) to track extra conditions they need to handle > cases similar as to how niter analysis computes it's 'assumptions' > condition. That allows the versioning to be done when there's an > actual beneficial transform (like vectorization) rather than just > upfront for the eventual chance that there'll be any. Ideally such > transform would then choose IVs in their transformed copy that > are analyzable w/o repeating such versioning exercise for the next > transform.
And it might be beneficial to perform some type promotion/demotion pass, either early during vectorization or separately before vectorization on a loop copy guarded with the ifns e.g. ifconv uses too. Find out what type sizes the loop use, first try to demote computations to narrower types in the vectorized loop candidate (e.g. if something is computed in a wider type only to have the result demoted to narrower type), then pick up the widest type size still in use in the loop (ok, this assumes we don't mix multiple vector sizes in the loop, but currently our vectorizer doesn't do that) and try to promote computations that could be promoted to that type size. We do partially something like that during vect patterns for bool types, but not other types I think. Jakub