public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: CSights <csights@fastmail.fm>
To: gcc-help@gcc.gnu.org
Subject: Re: binary compiled with -O1 and w/ individual optimization flags are  not the same
Date: Fri, 29 Feb 2008 22:38:00 -0000	[thread overview]
Message-ID: <200802291716.22197.csights@fastmail.fm> (raw)
In-Reply-To: <47C84379.983618F0@dessent.net>

Hi all,
	Thanks for your helpful hints.
	The first thing I did was compare the compiled program's output with -O2 
and -O2 -fno-strict-aliasing.  The differences did not go away 
using -fno-strict-aliasing, but it gave me a clue that I should be increasing 
the precision on the output to check for differences.
	Below is some output which does not match when viewed at high precision.  The 
output should match, because the number is calculated from the string 
sequence. (The output is two individuals' fitness in a genetic algorithm if 
that matters to you.)

-O2
0.879923389326927374298747963621281087398529052734375, "dadabda"

-O2 -fno-strict-aliasing 
0.87992338932692748532105042613693512976169586181640625, "dadabda"

	This makes me think that there is something going on with calculation of the 
number from the string of letters.  The calculation includes use of exp(), 
but I think that is the only special thing other than + - / *.
	I played around with "-msse -mfpunit=sse", but this doesn't seem to make a 
difference.  Are there any other math type stuff to try? Does the output of a 
program compiled with "-O2 -fno-strict-aliasing" not being the same give you 
all any clues?  Also, I tried -Wstrict-aliasing and -Wstrict-aliasing=1, but 
they didn't give any warnings/errors.

	Here are the output tests I've tried so far, and whether the output matches 
or not:
(-O1 == -O2 == -O2 -msse -mfpunit=sse == -O3) != (-O2 -fno-strict-aliasing) != 
(-O0 == -O0 -msse -mfpunit=sse)

	Does this suggest any further tests?

Thanks again,
	C.

P.S.  Thanks for the hint on how to view all the optimization flags activated 
by Ox.  I tried some tests adding the flags activated by O1 to the command 
line, but that didn't cause the output to be the same.  It seems the 
difference in output is from one of the non-flag optimizations activated by 
O1-3.

  reply	other threads:[~2008-02-29 22:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-29 17:28 CSights
2008-02-29 17:28 ` Andrew Haley
2008-02-29 17:40 ` Eljay Love-Jensen
2008-02-29 20:15 ` Brian Dessent
2008-02-29 22:38   ` CSights [this message]
     [not found]     ` <47C88B66.A501ABD6@dessent.net>
2008-03-01 15:59       ` CSights
2008-03-01 17:26         ` Tim Prince
2008-03-01 18:22         ` Brian Dessent
2008-03-05 18:13           ` CSights

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=200802291716.22197.csights@fastmail.fm \
    --to=csights@fastmail.fm \
    --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).