What compiler and optimization level is C++ compiled with?

I ask because I wrote a very simple solution to a problem that was reported back as being somewhere in the bottom 20% of solutions for RAM usage.

Surprised, I made the simplest hand-optimization that I could think of and shot into the top 20%

This is the initial version: https://godbolt.org/z/3K7MjM
This is the hand-optimized version: https://godbolt.org/z/qK79f5

As you will notice, at -O3 they emit the exact same machine code (which is why I never make those optimizations at work, they bring no value)

Comments (0)