Sometimes -O3 may not be the best option though. O2 is the most common used flag because it provides a balance between compile times and also efficiency.
Also O3 can in some cases be slower, like I said with vectorization, sometimes trying to optimise the code actually causes deoptimization. Meaning not all codebases can be compiled with O3 (well they can, but not recommended). For instance the linux kernel is only adviced to be compiled with O2 as O3 can break codebases as it permits the optimization to remove code which it deems inefficient or redundant, which can cause some code to break, wouldn't want something like the AMDGPU module to be handicapped by the compiler would you?
