This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: binary compiled with -O1 and w/ individual optimization flags are not the same


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]