How many GCC optimization levels are there?
I tried gcc -O1, gcc -O2, gcc -O3, and gcc -O4
If I use a really large number, it won't work.
However, I have tried
gcc -O100
and it compiled.
How many optimization levels are there?
How many GCC optimization levels are there?
I tried gcc -O1, gcc -O2, gcc -O3, and gcc -O4
If I use a really large number, it won't work.
However, I have tried
gcc -O100
and it compiled.
How many optimization levels are there?
There are four: -O0
(no optimization) up to -O3
(maximum). Everything else is the same as -O3
.
Five: -O0...-O3, and -Os.
Anything higher than O3 is the same as O3, and note that O3 may not always produce faster code than O2.
To be pedantic, there are 6 different valid -O options you can give to gcc, though there are some that mean the same thing. From the man page
-O (Same as -O1)
-O0 (do no optimisation, the default if no optimisation level is specified)
-O1 (optimise)
-O2 (optimise even more)
-O3 (optimise the most)
-Os (Optimize for size. -Os enables all -O2 optimizations that do not typically increase code size. It also performs further optimizations designed to reduce code size. -Os disables the following optimization flags: -falign-functions -falign-jumps -falign-loops -falign-labels -freorder-blocks -freorder-blocks-and-partition -fprefetch-loop-arrays -ftree-vect-loop-version)