Quantitative analysis of -Os vs -O3
Markus Trippelsdorf
markus@trippelsdorf.de
Sat Aug 26 09:05:00 GMT 2017
On 2017.08.26 at 01:39 -0700, Andrew Pinski wrote:
>
> First let me put into some perspective on -Os usage and some history:
> 1) -Os is not useful for non-embedded users
> 2) the embedded folks really need the smallest code possible and
> usually will be willing to afford the performance hit
> 3) -Os was a mistake for Apple to use in the first place; they used it
> and then GCC got better for PowerPC to use the string instructions
> which is why -Oz was added :)
> 4) -Os is used heavily by the arm/thumb2 folks in bare metal applications.
>
> Comparing -O3 to -Os is not totally fair on x86 due to the many
> different instructions and encodings.
> Compare it on ARM/Thumb2 or MIPS/MIPS16 (or micromips) where size is a
> big issue.
> I soon have a need to keep overall (bare-metal) application size down
> to just 256k.
> Micro-controllers are places where -Os matters the most.
>
> This comment does not help my application usage. It rather hurts it
> and goes against what -Os is really about. It is not about reducing
> icache pressure but overall application code size. I really need the
> code to fit into a specific size.
For many applications using -flto does reduce code size more than just
going from -O2 to -Os.
--
Markus
More information about the Gcc
mailing list