[ #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
Specifically compares Tail Recursion vs. Standard Recursion
Read more here: gapry.github.io/2026/01/31/A...
[ #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: gapry.github.io/2026/01/31/A...
For your viewing pleasure, some outtakes from the #AoCO2025 - see some of how the sausage was made!
youtu.be/8gASKxx6mCc?...
[ #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: gapry.github.io/2026/01/01/A...
Thanks to my Advent of Code Optimisation #AoCO2025 Compiler Explorer's shop sales have raised $1,780! Huge thanks to all who bought mugs, t shirts, desk mats and hoodies!!
Order yours: shop.compiler-explorer.com
I'll do a detailed breakdown of CE costs soon. Thanks everyone and Happy New Year!
A few folks have asked if there's a single list of the #AoCO2025 posts and there is: xania.org/AoCO2025-arc...
It's in reverse order but they're all there!
Thank **you** for having created #AoCO2025. It was well produced and really instructive. A great gift every day :)
Day 25 of #AoCO2025! 🎄 The final day! Thank you for joining this journey through compiler optimisations. From xor to vectorisation, it's been a wild ride. Happy holidays! 🎁
xania.org/202512/25-th...
youtu.be/N1sRfYwzmso
Day 24 of #AoCO2025! A loop summing 0+1+2+...+n. GCC unrolls it. Clang does something jaw-dropping: the loop vanishes entirely, replaced by a direct calculation. How?!
xania.org/202512/24-cu...
youtu.be/V9dy34slaxA
Day 23 of #AoCO2025! Switch → jump table? Sometimes. Other times: arithmetic, bitmasks, or something cleverer. Compilers have more tricks than you think.
xania.org/202512/23-sw...
youtu.be/aSljdPafBAw
Day 22: String comparison against "ABCDEFG" should call memcmp, but Clang inlines it with some clever memory tricks. How does it compare 7 bytes so efficiently? xania.org/202512/22-me... youtu.be/kXmqwJoaapg #AoCO2025
Just edited the last of the #AoCO2025. It's been a blast but holy smoke is it a bunch of work! Now time to go remind my wife what I look like :-)
Day 21: Summing integers? Compiler vectorises beautifully—8 at a time! Switch to floats? It refuses, doing each add individually. Same code, totally different output. Why? 🤔
xania.org/202512/21-ve...
youtu.be/lUTvi_96-D8
#AoCO2025
Day 20: Process 65,536 integers one at a time? Nah. The compiler vectorises it to handle 8 at once — same code, 8× faster! SIMD auto-vectorisation is compiler magic 🚀
xania.org/202512/20-si...
youtu.be/d68x8TF7XJs #AoCO2025
Day 19: Recursive functions calling themselves endlessly — stack growth? Nope! The compiler turns recursion into loops. Tail call optimisation is magic ✨
xania.org/202512/19-ta...
youtu.be/J1vtP0QDLLU #AoCO2025
Day 18: Function with fast & slow paths. Inline = code bloat. Don't inline = slow fast path. Can't have both—or can you? The compiler finds a surprising way out of this dilemma.
xania.org/202512/18-pa...
youtu.be/STZb5K5sPDs
#AoCO2025
Day 17: Inlining — the ultimate optimisation ✨
A function gets inlined, half vanishes. The assembly is cleaner than hand-written. How does copy-paste make code disappear?
xania.org/202512/17-in...
youtu.be/JFHfFTvMPp0
#AoCO2025
Day 16: Calling conventions matter! Pass 8 chars as separate args: stack spillage. Pack them in a struct: single register. Sometimes structs are MORE efficient than separate parameters!
xania.org/202512/16-ca...
youtu.be/Yaw8AMoP4sI
#AoCO2025
Day 15: Two nearly identical loops—one writes to memory every iteration, the other stays in registers. Same code, wildly different performance. The culprit? Aliasing!
xania.org/202512/15-al...
youtu.be/PPJtJzT2U04
#AoCO2025
Day 14: Add ONE global counter to your loop and watch LICM vanish—strlen called every iteration! Why would incrementing an unrelated variable break the optimisation? 🤔
xania.org/202512/14-li...
youtu.be/OwFNblEEAXo
#AoCO2025
Passed the halfway point of the #AoCO2025 (!!) where has the time gone?!
Day 13 of Advent of Compiler Optimisations! 🔄
Loop calling a function whose result never changes? One compiler hoists it out automatically. The other… doesn't. Even with hints!
xania.org/202512/13-li...
youtu.be/dIwaqJG0WDo
#AoCO2025
Day 12 of Advent of Compiler Optimisations! A loop that checks the same thing every time. The compiler's solution? Make the code bigger to make it faster. Wait, what? xania.org/202512/12-lo... youtu.be/-VCrYshE7iQ #AoCO2025
Day 11: A clever bit-counting loop using the "clear bottom bit" trick. Change one compiler flag and... wait, what just happened to my loop?! Pattern recognition at its finest.
xania.org/202512/11-po...
youtu.be/Hu0vu1tpZnc
#AoCO2025
Cripes, heading towards 20k humans who liked what I do enough to subscribe to my YT videos! 10 #AoCO2025 videos in, 15 to go... I've filmed most of them and edited up to 17, but it's a lengthy process (!) Hopefully I can keep ahead of the calendar :-)
Day 10: Fixed loop count? Compiler transforms code surprisingly. At 50 iterations it switches strategy. What's the cutoff and why?
xania.org/202512/10-lo...
youtu.be/HvF3tF2efEA
#AoCO2025
Day 9: Why does the compiler keep an "expensive" multiply in the loop instead of using clever addition tricks? The slower operation enables something more valuable. What's the hidden benefit?
xania.org/202512/09-in...
youtu.be/vZk7Br6Vh1U
#AoCO2025
Day 8 of Advent of Compiler Optimisations! 🔄
Index-based for vs pointer while vs range-for vs std::accumulate—which is fastest? Three produce identical assembly, but one doesn't!
xania.org/202512/08-go...
youtu.be/FB8Hgj3TpJM
#AoCO2025
Day 7: Dividing by 10 compiles to... no division at all!
How does the compiler pull this off? Magic constants, bit shifts, and a clever arithmetic trick.
xania.org/202512/07-di...
youtu.be/V9Pvv1tkocM
#AoCO2025
Day 6 of Advent of Compiler Optimisations! Divide by 512—just a shift, right? But the compiler adds extra instructions. Why? A subtle difference between what you asked and what you meant!
xania.org/202512/06-di...
youtu.be/7Rtk0qOX9zs
#AoCO2025