This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Enabling loop unrolls at -O3?
Robert Dewar <dewar@adacore.com> writes:
>> Including loop unrolling to -O2 is IMNSHO a bad idea, as loop unrolling
>> increases code size, sometimes a lot. And the distinction between -O2
>> and -O3 is exactly in the space-for-speed tradeoffs.
>That's certainly a valid way of defining the difference (and certainly
>used to be the case in the old days when the principle extra optimization
>was inlining)
But even -O2 makes several space-for-speed optimisations (multiply by
shifting and adding, align jump targets, etc), so this cannot define
the difference between -O2 and -O3. It is more quantitative in nature:
-O2 only generates bigger code where the payoff in speed is almost
certain, which is not always the case for unrolling/inlining.
Still, more and more projects seem to be switching to -Os for everything
which could be interpreted as both a consequence of the inevitable
bloating of large programs but also as a dissatisfaction with what -O2/3
does to the code. Or maybe they are wisening up and actually using the
option that has been there all along.