public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: "Dr. David Kirkby" <david.kirkby@onetel.net>
Cc: gcc-help@gcc.gnu.org
Subject: Re: How safe is gcc -O3 ?
Date: Tue, 20 Jul 2010 14:30:00 -0000	[thread overview]
Message-ID: <mcr7hkqh8rs.fsf@google.com> (raw)
In-Reply-To: <4C44F318.8020609@onetel.net> (David Kirkby's message of "Tue, 20	Jul 2010 01:51:36 +0100")

"Dr. David Kirkby" <david.kirkby@onetel.net> writes:

> How safe is it to distribute code for others to build, where you have
> selected -O3 for them? I'm a bit concerned that might be a bit
> aggressive to use as a default, given it will potentially be compiled
> by different gcc versions on different platforms.

The -O3 optoin should be safe for correct code.  An important difference
between -O2/-O3 and -O1 is that -O2 and -O3 enable strict aliasing and
strict overflow.  Those options provide better optimization for correct
code, but are far more likely to cause unexpected code generation for
incorrect code.  See the -fstrict-aliasing and -fstrict-overflow
options.

> I believe -O2 might be a more sensible default, but would welcome the
> opinions of others on the matter.

The main difference between -O3 and -O2 is that -O3 enables more
speculative optimizations.  These should not miscompile your code, but
they may cause your program to run more slowly.

Ian

      parent reply	other threads:[~2010-07-20  8:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-20  2:05 Dr. David Kirkby
2010-07-20  2:35 ` NightStrike
2010-07-20  8:08   ` Dr. David Kirkby
2010-07-20 14:30 ` Ian Lance Taylor [this message]

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=mcr7hkqh8rs.fsf@google.com \
    --to=iant@google.com \
    --cc=david.kirkby@onetel.net \
    --cc=gcc-help@gcc.gnu.org \
    /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).