Re: Need some clarification about optimization flags, what "exactly" does -O1 do?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andrzej Giniewicz wrote:

> g++ -c -Q -O0 --help=optimize > 0.flags
> g++ -c -Q -O1 --help=optimize > 1.flags
> diff 0.flags 1.flags | grep enabled
> 
> the problem is that I was able to add all flags returned by above
> commands! Is there some secret things that -O1 do instead of only
> lighting those -f*** flags listened by above commands? If above
> returned me:

When you specify -O0 (or no -O at all) you are telling the compiler to
perform no optimization, and therefore all those -f options become
no-ops -- the code whose behavior would be modified by their presence
has been bypassed entirely.

Moreover, as the manual explains, not all optimizations have a
corresponding -f flag, some are controlled directly by the -O level.  So
you absolutely cannot treat -O as being composed of a bunch of -f
options.

> the problem is that any diagnostic, stwich/case/if for that value
> equal HardwareIndexBuffer::IT_32BIT or HardwareIndexBuffer::IT_16BIT
> fail, simple cout on it says it's 104... always, every run - every
> build with anything more than -O0... it's working on -O0 thought and
> -O0 with above flags... anyway for now question is rather about what
> more than flags returned by those 3 mentioned lines of shell does -O1
> do because I can just go on with disabling one feature and leaving
> rest in place

The only way that anyone's going to be able to offer any concrete help
is with a testcase that reproduces the problem, something that is
standalone and ideally reduced as much as possible.  There is a small
chance that there is a genuine compiler bug, but a larger chance that
some aspect of your code is invoking undefined behavior which results in
a program that exhibits seemingly irrational and completely nonsensical
behavior.  For instance recent versions of gcc can be very sensitive to
aliasing violations and signed integer overflow; however that level of
strictness is not enabled by default at -O1 so I suspect that it's
something else.

Brian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux