User: Password:
|
|
Subscribe / Log in / New account

Rethinking optimization for size

Rethinking optimization for size

Posted Jan 31, 2013 21:48 UTC (Thu) by mstefani (guest, #31644)
In reply to: Rethinking optimization for size by epa
Parent article: Rethinking optimization for size

The compiler has no chance to know on which CPU the code will run in the end.
Unless you're Gentoo it is highly likely that your binaries were compiled on a totally different CPU.


(Log in to post comments)

Rethinking optimization for size

Posted Feb 1, 2013 10:51 UTC (Fri) by epa (subscriber, #39769) [Link]

The compiler has no chance to know on which CPU the code will run in the end.
The programmer can tell it, if not the exact CPU, then at least the family or families to optimize for. The -march and -mcpu options already affect code generation in the choice of instructions; it's strange that there is little connection from that to the higher-level optimizations that are applied.

The developer building Fedora, etc, also doesn't know on which CPU it will be run, but you can make a reasonable guess and try to use optimizations that perform well on typical target hardware. That won't be the same set of optimizations that worked on a typical i486, even if you exclude things that require new instruction set support. Yet the set of optimizations chosen by -O and -O2 is essentially fixed and gcc doesn't use its knowledge of the target CPU to influence that set.

Rethinking optimization for size

Posted Feb 7, 2013 14:50 UTC (Thu) by engla (guest, #47454) [Link]

GCC does have options for this. -mtune to optimize for a cpu without losing generality, -mcpu to optimize and use exclusive instruction sets etc.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds