Lexicon Entry
-O2
-O2 is a common compiler flag used in GCC and Clang that enables most optimizations that do not involve a space-speed tradeoff, providing a strong balance between compilation time and execution speed.
Related Knowledge & Cross-References
Guide
The Ultimate Guide to Compiler Optimization Passes: Boosting Performance with -O2
You have written your code, but how does the compiler make it run three times faster when you enable optimizations? We demystify compiler optimization passes and see exactly what happens under the hood.