cgccoptimization

How many GCC 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?


Solution

  • To be pedantic, there are 8 different valid -O options you can give to gcc, though there are some that mean the same thing.

    The original version of this answer stated there were 7 options. GCC has since added -Og to bring the total to 8.

    From the man page:

    There may also be platform specific optimizations, as @pauldoo notes, OS X has -Oz.