On Wed, May 26, 2021 at 11:50:07AM +0200, Richard Biener wrote: > > We can split the loop into two loops: > > > > while (++k > n) > > a[k] = b[k] + 1; > > while (l++ < n) > > a[k] = b[k] + 1; > > > > then for the second loop, it could be optimized. > > Btw, I think even the first loop should be vectorized. I see we do > not handle it in niter analysis: > > Analyzing loop at t.c:3 > t.c:3:14: note: === analyze_loop_nest === > t.c:3:14: note: === vect_analyze_loop_form === > t.c:3:14: note: === get_loop_niters === > t.c:3:14: missed: not vectorized: number of iterations cannot be > computed. > > but the number of iterations should be UINT_MAX - k (unless I'm > missing sth), may_be_zero would be sth like k < n. It would be > nice to not split this into loops that niter analysis cannot handle ...
As long as it doesn't do that for signed loop counters, because that would be a waste -- ever executing such code is UB, so vectorising it will only cost extra insns (usually). Segher