This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: binary compiled with -O1 and w/ individual optimization flags are not the same
- From: Andrew Haley <aph at redhat dot com>
- To: CSights <csights at fastmail dot fm>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 29 Feb 2008 17:27:41 +0000
- Subject: Re: binary compiled with -O1 and w/ individual optimization flags are not the same
- References: <200802291215.47293.csights@fastmail.fm>
CSights wrote:
Hi,
I'm trying to debug some mismatching results from a program compiled with
O1,2,3) and without (-O0 or nothing) optimization flags.
My thought was to individually turn on optimization flags and see which one
changes the program's output.
Unfortunately for this plan, the binaries produced using -O1 and those flags
said to be turned on by g++ in the manual (-fdefer-pop -fdelayed-branch
-fguess-branch-probability -fcprop-registers -fif-conversion -fif-conversion2
-ftree-ccp -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-ter -ftree-lrs
-ftree-sra -ftree-copyrename -ftree-fre -ftree-ch -funit-at-a-time -fmerge-constants)
do not match.
No, they wouldn't: without -O you get no optimizations. Doesn't matter
what individual opt flags you put on the command line.
I also tried without -fdelayed-branch b/c it is not supported
on my architectures (i386: athlon xp, core duo) and with -fomit-frame-pointer
in case that was the difference.
I've tried this with g++ versions
g++ (GCC) 4.2.3 (Debian 4.2.3-1)
and
i686-apple-darwin8-g++-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5363)
Is there a way to have g++ tell me which flags it is actually using when
compiling a program. E.g. expand -O1 to the individual optimization flags at
run time?
-save-temps -fverbose-asm puts all the optimizations into the .s file.
Anyone have any other suggestions?
Being a bit more scientific, what is the difference between runs?
Andrew.