[ #Compiler ] Day 3 of #AoCO2025 Study Notes: You can’t fool the optimiser

My notes focus on reproducing and verifying Matt Godbolt’s teaching within a local development environment

This post specifically compares Tail Recursion vs. Standard Recursion.

Read more here: https://gapry.github.io/2026/01/31/Advent-of-Compiler-Optimisations-Study-Notes-03.html

Study Notes: You can’t fool the optimiser

Study Notes: You can’t fool the optimiser

Gapry's Blog

[ #Compiler ] Day 2 of #AoCO2025 Study Notes

My notes focus on reproducing and verifying Matt Godbolt’s teaching within a local development environment

Additionally, I have extended the discussion by implementing a manual PoC in assembly

Read more here: https://gapry.github.io/2026/01/31/Advent-of-Compiler-Optimisations-Study-Notes-02.html

Study Notes: Addressing the adding situation

Study Notes: Addressing the adding situation

Gapry's Blog

[#Compiler] Day 1 of #AoCO2025 Study Notes

While the original uses #CompilerExplorer, I wanted to replicate the analysis locally.

In this post, I have used #gcc, #clang, llvm-objdump and #LLDB to analyze.

Read more here: https://gapry.github.io/2026/01/01/Advent-of-Compiler-Optimisations-Study-Notes-01.html

Study Notes: Why xor eax, eax?

Study Notes: Why xor eax, eax?

Gapry's Blog

Day 25 of Advent of Compiler Optimisations!

We've reached the end of this journey through compiler magic—from simple arithmetic tricks to mind-bending loop transformations. Thank you for following along! Whether you celebrate Christmas or just enjoy a good compiler optimisation, I hope you've discovered something that made you see your code differently.

Read more: https://xania.org/202512/25-thank-you
Watch: https://youtu.be/N1sRfYwzmso

#AoCO2025

Thank you — Matt Godbolt’s blog

The end of the 2025 Advent of Compiler Optimisation

Day 24 of Advent of Compiler Optimisations!

A simple loop that sums integers from 0 to n. GCC cleverly unrolls it to process two numbers at once. But clang? The loop completely disappears—replaced by a few multiplies and shifts that compute the answer directly. How does it recognise this pattern and transform O(n) code into O(1)?

Read more: https://xania.org/202512/24-cunning-clang
Watch: https://youtu.be/V9dy34slaxA

#AoCO2025

When compilers surprise you — Matt Godbolt’s blog

Sometimes compilers can surprise and delight even a jaded old engineer like me

Day 23 of Advent of Compiler Optimisations!

Switch statements compile to jump tables, right? Well... sometimes. But what happens when your five-case switch becomes pure arithmetic? Or when checking for whitespace turns into a single mysterious constant and some bit manipulation? Turns out compilers have a whole bag of tricks beyond the textbook answer.

Read more: https://xania.org/202512/23-switching-it-up
Watch: https://youtu.be/aSljdPafBAw

#AoCO2025

Switching it up a bit — Matt Godbolt’s blog

Taking a look at the various ways the compiler can optimise switch statements

Day 22 of Advent of Compiler Optimisations!

Comparing a string_view against "ABCDEFG" should call memcmp, right? Watch what Clang actually generates — no function call at all, just a handful of inline instructions using some rather cunning tricks. How does it compare 7 bytes so efficiently when they don't fit in a single register?

Read more: https://xania.org/202512/22-memory-cunningness
Watch: https://youtu.be/kXmqwJoaapg

#AoCO2025

Clever memory tricks — Matt Godbolt’s blog

We learn that compilers have tricks to access memory efficiently

Day 21 of Advent of Compiler Optimisations!

Summing an array of integers? The compiler vectorises it beautifully, processing 8 at a time with SIMD. Switch to floats and... the compiler refuses to vectorise, doing each add one by one. Same loop, same code structure — why does the compiler treat floats so differently?

Read more: https://xania.org/202512/21-vectorising-floats
Watch: https://youtu.be/lUTvi_96-D8

#AoCO2025

When SIMD Fails: Floating Point Associativity — Matt Godbolt’s blog

Why floating point maths doesn't vectorise like integers, and what to do about it

Day 20 of Advent of Compiler Optimisations!

Loop over 65,536 integers doing comparisons — that's 65,536 iterations, right? Wrong! With the right flags, the compiler processes 8 integers per iteration using SIMD instructions. Same number of assembly instructions, 8× the throughput. What's the trick that makes this possible?

Read more: https://xania.org/202512/20-simd-city
Watch: https://youtu.be/d68x8TF7XJs

#AoCO2025

SIMD City: Auto-vectorisation — Matt Godbolt’s blog

Doing more with less: vectorising can speed your code up 8x or more!

Day 19 of Advent of Compiler Optimisations!

Recursive functions need to call themselves over and over — that must mean unbounded stack growth, right? Wrong! When a function ends by calling another function (even itself), the compiler can replace the call with a simple jump. Recursion becomes iteration, no stack overhead at all. How does this transformation work?

Read more: https://xania.org/202512/19-tail-call-optimisation
Watch: https://youtu.be/J1vtP0QDLLU

#AoCO2025

Chasing your tail — Matt Godbolt’s blog

The art of not (directly) coming back: tail call optimisation