Mail Archives: djgpp/1998/09/17/03:00:18
Eli Zaretskii wrote:
> On Tue, 15 Sep 1998, Arthur wrote:
>
> > What does -fstrength-reduce do, exactly, and why do some people report such
> > a huge speed increase when using it?
>
> -fstrength-reduce replaces expensive instruction by less expensive
> ones. For example, multiplication is replaced with additions or bit
> shifts, etc.
>
> The problem is that this usually needs extra registers, and x86 has a
> few of them to spare. If a function doesn't use too many registers,
> then -fstrength-reduce can be a big win; but if they are all used,
> -fstrength-reduce in a loop can mean a significant slowdown, since GCC
> will have to constantly reload some of the regsiters.
Oh, -fstrength-reduce does that too? I read somewhere that -fstrength-reduce it
is more of a loop optimization that does stuff like converting
for (i = 0; i < 100; i++)
into
for (temp = 100, i = 0; --temp; i++)
saving a cycle or two at the end of each iteration, and a few bytes of code per
loop.
- Raw text -