Search notes:

gcc -O

Specify optimization;
-O0 (Oh zero): Optimize for compilation time (which is the default optimization mode)
-O1 Try to reduce code size and execution time without increasing compilation time too much. (equal to -O)
-O2 Optimize more
-O3 Optimize even more
-Os Optimize for size. See also -fomit-frame-pointer.
-oz Opimize more aggresively for size than with -Os. Introduced with GCC 12.1
-Ofast implies -O3 -ffast-math -fno-protect-parens -fallow-store-data-races -fstack-arrays -fno-semantic-interposition
-Og Optimize for debugging. -Og does not imply -g.

See also

-O is not the same as the lowercase -o option.
GCC options

Index