<div dir="ltr">Folks,<div><br></div><div style>I'm trying to rationalize about optimization levels and maybe we should come up with a document like this:</div><div style><br></div><div style><a href="http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html">http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html</a><br>
</div><div style><br></div><div style>Though, I remember a discussion a few months ago, and some people recommended we had names, rather than numbers, to dissociate the idea that 3 is better than 2. Regardless, would be good to have some guidelines on what goes where, so we don't end up in yet another long discussion about where to put the optimization <insert-name-here>.</div>
<div style><br></div><div style>As far as I can get from our side is:<br></div><div style><br></div><div style>-O3 : throw everything and hope it sticks</div><div style>-O2 : optimized build, but should not explode in code size nor consume all resources while compiling</div>
<div style>-O1 : optimized debug binaries, don't change the execution order but remove dead code and stuff</div><div style>-O0 : don't touch it</div><div style>-Os : optimize, but don't run passes that could blow up code. Try to be a bit more drastic when removing code. When in doubt, prefer small, not fast code.</div>
<div style>-Oz : only perform optimizations that reduce code size. Don't even try to run things that could potentially increase code size.</div><div style><br></div><div style>I've been thinking about this, and I think, regarding those criteria, it would make sense to use a try/compare/rollback approach to some passes, at least the most dramatic ones.</div>
<div style><br></div><div style>For instance, the vectorizer keeps the old loops hanging, and under Os/Oz, it should be possible to rollback the pass if the end result is bigger. Of course, IR size has little to do with final code size, but that's why we have (and rely so much on) heuristics.</div>
<div style><br></div><div style>AFAIK, for that to work on any pass as they are, we'd have to implement a transactional model on IRBuilder, which is not trivial, but could be done. Does anyone have a strong opinion about this?</div>
<div style><br></div><div style>cheers,<br></div><div style>--renato</div></div>