Master the fundamental concepts of compiler optimization techniques through this focused micro-challenge.
GCC and Clang -O0 through -O3 and -Os change inlining, vectorization, and alias assumptions. Production servers compile hot paths at -O2 or -O3; debug builds stay at -O0 so breakpoints line up with source.
-O2: standard optimizations without aggressive size blowup. -O3: more inlining and vectorization. -ffast-math: relaxes IEEE rules for speed. -g does not disable optimizations.
bashLoading…
size and nm when code bloat appears-fomit-frame-pointer speeds x86 but breaks naive stack walks-S to inspect assembly when a loop did not vectorizeKeep the relevant documentation open while you implement. When your output disagrees with the reference, trace one failing case by hand before changing random lines.
You will compile the same program at -O0, -O2, and -O3 and compare runtime and binary size. This exercise asks you to attribute one speedup to a specific optimization visible in assembly.
Compare compiler optimization levels by examining assembly output.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github