[autovect] [patch] enchance vectorizer for ivs after loop
Dorit Nuzman
DORIT@il.ibm.com
Thu Feb 9 10:10:00 GMT 2006
> Hello,
>
> > > on loops like
> > >
> > > for (i = 0; i < 64; i++)
> > > {
> > > x = 10 * i + 5;
> > > A[i] = B[i];
> > > }
> > >
> > > use (x);
> > >
...
> >
> > scev_const_prop should already do this optimization (calculate the
final
> > value of x and replace use(x) with it), and thus, you should only need
> > to run it before vectorization.
>
> and actually, scev_const_prop is run before vectorizer, optimizes out x,
> and the loop is successfully vectorized, for all the proposed testcases.
> So I somewhat miss the point of the patch.
>
the point was to be able to handle cases in which the iv is used after the
loop and cannot be taken out of loop. The thing is, scev_const_prop is
disabled on autovect-branch right now, which is probably why we didn't see
that this patch can be useful in a (much?) more limited set of cases... The
question is - are there such cases at all...? This is the testcase I
originally had in mind:
int foo (short *p, int len)
{
int sum = 0;
for ( ; i > 1; i-=2)
sum += *p++;
return i + sum;
}
On mainline scev_const_prop does not optimize away the use of i out of the
loop, but actually vectorization fails earlier, because the loop bound
cannot be computed:
...
(set_nb_iterations_in_loop = scev_not_known))
...
vv.c:6: note: not vectorized: number of iterations cannot be
computed.
Whereas on autovect-branch the loop bound is successfully computed:
Symbolic number of iterations is (unsigned int) (len_5 - 2) /[fl] 2 +
1
but we fail to vectorize because of the iv that is used after the loop
(unless we use the patch).
I guess if the loop bound would have been resolved on mainline,
scev_const_prop would have taken the iv out of the loop (?). Why does
mainline give up on computing the number of iterations?
thanks,
dorit
> Zdenek
More information about the Gcc-patches
mailing list