[cfg-branch] unroll-new cleanups
Zdenek Dvorak
rakdver@atrey.karlin.mff.cuni.cz
Mon Apr 29 06:52:00 GMT 2002
> > Hello.
> >
> > > > To be able to handle overflow, we must at least ensure that number of unrolling
> > > > is a power of 2.
> > >
> > > Why?
> >
> > Consider
> >
> > for (i=1;i!=0;i++)
> > do_something ();
> >
> > if you unroll this (say) 3 times, in which copy will it exit? It depends on
> > what is range of i's type modulo 3; perhaps it can be handled somehow, but it
> > is much easier to unroll it with number of unrollings being power of two, when
> > we use the fact that this number is always 0.
>
> Is this corect
> If I will set number of unrollings to 4, and we unroll the "usual way"
>
> for (i=1;i!=0;i+=4)
> {
> do_something ();
> do_something ();
> do_something ();
> do_something ();
> }
>
> it will never get to zero...
But we do not unroll it this way, of course. What we currently do
(after lot of simplifying) is
do_something ();
do_something ();
do_something ();
i=4;
for (;i!=0;i+=4)
{
do_something ();
do_something ();
do_something ();
do_something ();
}
> I think we should compute that the loop has 0xff iterations (lets count in
> unsigned chars) and unroll by something that divides 255, lets say 5 times.
This makes no sense to me, sorry. Could you explain more precisely?
Zdenek
More information about the Gcc-patches
mailing list