-O1 instructs the compiler to leave some optimizations on the table. If you want the fastest code the compiler can generate, you want -O2 or -O3.
This is true for clang and gcc.
-O1 instructs the compiler to leave some optimizations on the table. If you want the fastest code the compiler can generate, you want -O2 or -O3.
This is true for clang and gcc.
In extreme cases, GCC/Intel/MSVC are able to optimize pure C code with auto-vectorization and SSE/AVX instructions, possibly better than hand crafted ASM... but the compiler will never do that if not given the flags to allow it.
EG: ICC has a AVX version of atan2(), which you can use through intrinsics[0]. But it refused to vectorize even the simplest loop with the function call in it. Even with every possible fast-math flag or every #pragma(please vectorize), it wouldn't do it. I assume due to reduced precision? Nothing I could find online had the answer (again, 4 years ago)
What I actually think happened is he didn't understand that there were higher optimization levels that -O1, which gives his code an advantage when compared to the c code implementation.