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]

Optimization settings actual effects


Hello everyone,

I don't have a question, I merely have a little bash script that can generate some interesting output for those who are curious as to what the different optimization settings do.

Here's the bash script:
------------8<------------
touch optimization_settings.cpp
fn () {
if test -n "$1"; then
g++ "$1" -S -fverbose-asm -o optimization_settings.out optimization_settings.cpp
else
g++ -S -fverbose-asm -o optimization_settings.out optimization_settings.cpp
fi
sed -e 's/\([^#]\) -/\1\
# -/g' optimization_settings.out > "$2"
}

fn "" gcc-default
fn -O gcc-O
fn -O0 gcc-O0
fn -O1 gcc-O1
fn -O2 gcc-O2
fn -O3 gcc-O3
fn -Os gcc-Os

unset -f fn
rm optimization_settings.cpp
rm optimization_settings.out
------------8<------------

The different "gcc-xxxx" files can be diff'd against one another to ascertain the differences between the optimization settings.  I strongly suspect that the settings are relative to the platform.

Hope someone finds this useful.  And my thanks to the person that mentioned the utility value of the -fverbose-asm flag!

Sincerely,
--Eljay

"Hmmm, so that's the only difference between -O2 and -Os!?  Well........."



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