Statements are independent: if you stop the program with a breakpoint between statements, you can then assign a new value to any variable or change the program counter to any other statement in the function and get exactly the results you expect from the source code.
The compiler performs optimization based on the knowledge it has of the program. Compiling multiple files at once to a single output file mode allows the compiler to use information gained from all of the files when compiling each of them.
Not all optimizations are controlled directly by a flag. Only optimizations that have a flag are listed in this section.
Most optimizations are completely disabled at -O0 or if an -O level is not set on the command line, even if individual optimization flags are specified. Similarly, -Og suppresses many optimization passes.
Depending on the target and how GCC was configured, a slightly different set of optimizations may be enabled at each -O level than those listed here. See Overall Optionsfor examples. Optimizing compilation takes somewhat more time, and a lot more optimization of options for a large function.
With -Othe compiler tries to reduce code size and execution time, without performing any optimizations that take a great deal of compilation time. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff.
As compared to -Othis option increases both compilation time and the performance of the generated code.