From: Brian Dessent <brian@dessent.net>
To: Andrzej Giniewicz <gginiu@gmail.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Need some clarification about optimization flags, what "exactly" does -O1 do?
Date: Thu, 27 Nov 2008 11:23:00 -0000 [thread overview]
Message-ID: <492E820A.67D22F3B@dessent.net> (raw)
In-Reply-To: <f6d5b6a20811270221jce1e76al39ceded1a3508a81@mail.gmail.com>
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
next prev parent reply other threads:[~2008-11-27 11:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-27 11:19 Andrzej Giniewicz
2008-11-27 11:23 ` Brian Dessent [this message]
2008-11-27 11:34 ` Andrew Haley
2008-11-27 11:42 ` Andrzej Giniewicz
[not found] ` <f6d5b6a20811270333h3764c9a5jee3dbd95e6e76206@mail.gmail.com>
2008-11-27 14:33 ` Andrew Haley
2008-11-28 10:54 ` Andrzej Giniewicz
2008-11-28 11:29 ` Andrew Haley
2008-11-28 19:16 ` Andrzej Giniewicz
2008-11-29 11:50 ` Andrew Haley
2008-11-29 19:28 ` Andrzej Giniewicz
2008-11-29 20:43 ` Andrzej Giniewicz
2008-11-30 12:12 ` Andrew Haley
2008-11-28 23:37 ` Diego Novillo
2008-11-29 18:28 ` Andrew Haley
2008-12-01 12:44 ` John (Eljay) Love-Jensen
2008-11-28 19:03 ` Michael Meissner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=492E820A.67D22F3B@dessent.net \
--to=brian@dessent.net \
--cc=gcc-help@gcc.gnu.org \
--cc=gginiu@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).