Optimization Switches
Hi, I wish to selectively enable specific optimizations to observe its effect on the source. My project requires me to do this analysis. It seemed, the -f* flags would enable me to do that. But it turns out that individual optimizations can't be enabled like that, and all the optimizations at a specific level gets enabled when I use a -Ox switch. This faq at http://gcc.gnu.org/wiki/FAQ#optimization-options, says this too. So here are my two questions : a) Is there any way to observe the effect of a particular optimization, without the obvious option of using a lot of -fno switches. b) And do the -f* switches serve any purpose, if I can't enable individual optimizations using them. Thanks, Sharjeel Imam
Re: Optimization Switches
On Friday 27 August 2010 06:07 AM, Paul Brook wrote: Hi, I wish to selectively enable specific optimizations to observe its effect on the source. My project requires me to do this analysis. It seemed, the -f* flags would enable me to do that. But it turns out that individual optimizations can't be enabled like that, and all the optimizations at a specific level gets enabled when I use a -Ox switch. This faq at http://gcc.gnu.org/wiki/FAQ#optimization-options, says this too. So here are my two questions : a) Is there any way to observe the effect of a particular optimization, without the obvious option of using a lot of -fno switches. b) And do the -f* switches serve any purpose, if I can't enable individual optimizations using them. I suspect that in practice that this isn't a particularly interesting question. Optimizations often interact with each other in complex ways, with the end result being significantly different to the naive sum of their parts. Paul This is precisely what I want, segregating the effect of every single optimization. :) -- Sharjeel
Re: Optimization Switches
On Thursday 26 August 2010 11:02 PM, Jonathan Wakely wrote: On 26 August 2010 12:56, wrote: a) Is there any way to observe the effect of a particular optimization, without the obvious option of using a lot of -fno switches. b) And do the -f* switches serve any purpose, if I can't enable individual optimizations using them. You need an optimisation option, -Ox, to enable optimisations, but you don't have to use -O2 to get optimisations that are normally enabled by -O2, e.g. -O1 -fstrict-aliasing will enable strict aliasing. So to answer the first question, use -O1, turn off the O1 optimisations you don't want, and selectively enable the ones you do want. Thanks a lot.