Re: What optimizations does -O really do?
Re: What optimizations does -O really do?
- Subject: Re: What optimizations does -O really do?
- From: James Walker <email@hidden>
- Date: Tue, 29 May 2007 12:29:21 -0700
Lawrence Gold wrote:
On May 25, 2007, at 12:53 PM, James Walker wrote:
I have an application that uses C++ and OpenGL, and I noticed that the
3D view flickers when the code is compiled with optimization, and does
not flicker when the code is compiled with no optimization. (Xcode
2.4.1, 10.4u SDK, on a G5.) I thought it might give me a clue if I
figured out exactly which optimization triggered the problem. So I
looked in "man gcc", which told me that -O implies
-fdefer-pop -fdelayed-branch -fguess-branch-probability
-fcprop-registers -floop-optimize -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
-fmerge-constants
and maybe -fomit-frame-pointer. If I put all those in "Other C++
flags", there is no flicker, but if I put -O there, it flickers. It
appears that -O must be doing something else, but what?
One way to find which flags are set is to use the -v and -Q options:
g++ -v -Q test.cpp
With -O, I get
options passed: -v -D__DYNAMIC__ -fPIC -march=nocona -auxbase -O
-D__private_extern__=externoptions enabled: -fPIC
-falign-jumps-max-skip -falign-loops -falign-loops-max-skip
-fargument-alias -fbranch-count-reg -fcommon -fcprop-registers
-fdefer-pop -feliminate-unused-debug-types -fexceptions -ffunction-cse
-fgcse-lm -fguess-branch-probability -fident -fif-conversion
-fif-conversion2 -fivopts -fkeep-static-consts -fleading-underscore
-floop-optimize -floop-optimize2 -fmerge-constants -fpeephole
-freg-struct-return -fsched-interblock -fsched-spec
-fsched-stalled-insns-dep -fsplit-ivs-in-unroller -ftree-ccp -ftree-ch
-ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-fre
-ftree-loop-im -ftree-loop-ivcanon -ftree-loop-optimize -ftree-lrs
-ftree-pre -ftree-sra -ftree-ter -fvar-tracking
-fzero-initialized-in-bss -m80387 -mhard-float -mno-soft-float -mieee-fp
-mfp-ret-in-387 -maccumulate-outgoing-args -mmmx -msse -msse2
-m128bit-long-double -mno-red-zone -mtune=nocona -march=nocona
With -O0, I get
options enabled: -fPIC -falign-jumps-max-skip -falign-loops
-falign-loops-max-skip -fargument-alias -fbranch-count-reg -fcommon
-feliminate-unused-debug-types -fexceptions -ffunction-cse -fgcse-lm
-fident -fivopts -fkeep-static-consts -fleading-underscore
-floop-optimize2 -fpeephole -freg-struct-return -fsched-interblock
-fsched-spec -fsched-stalled-insns-dep -fsplit-ivs-in-unroller
-ftree-loop-im -ftree-loop-ivcanon -ftree-loop-optimize -fvar-tracking
-fzero-initialized-in-bss -m80387 -mhard-float -mno-soft-float -mieee-fp
-mfp-ret-in-387 -maccumulate-outgoing-args -mmmx -msse -msse2
-m128bit-long-double -mno-red-zone -mtune=nocona -march=nocona
I'll let you figure out what's different between those. :-)
Thanks. For the record, the differences are
-fcprop-registers
-fdefer-pop
-fguess-branch-probability
-fif-conversion
-fif-conversion2
-floop-optimize
-fmerge-constants
-ftree-ccp
-ftree-ch
-ftree-copyrename
-ftree-dce
-ftree-dominator-opts
-ftree-dse
-ftree-fre
-ftree-lrs
-ftree-pre
-ftree-sra
-ftree-ter
Comparing this to the documented list for -O, I don't see
-fdelayed-branch and do see -ftree-pre.
--
James W. Walker, Innoventive Software LLC
<http://www.frameforge3d.com/>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden