Optimization settings actual effects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux