Advertisement · 728 × 90
#
Hashtag
#AoCO2025
Advertisement · 728 × 90
Study Notes: You can’t fool the optimiser Study Notes: You can’t fool the optimiser

[ #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...

0 0 0 0
Study Notes: Addressing the adding situation Study Notes: Addressing the adding situation

[ #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...

0 0 0 0
[AoCO 26/25] Outtakes
[AoCO 26/25] Outtakes YouTube video by Matt Godbolt

For your viewing pleasure, some outtakes from the #AoCO2025 - see some of how the sausage was made!
youtu.be/8gASKxx6mCc?...

29 0 0 0
Study Notes: Why xor eax, eax? Study Notes: Why xor eax, eax?

[ #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...

1 0 0 0
Preview
Compiler Explorer The official Compiler Explorer shop! Come show your support for CE and get cool gear!

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!

46 3 2 0
AoCO2025 Archive — Matt Godbolt’s blog

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!

35 6 1 0

Thank **you** for having created #AoCO2025. It was well produced and really instructive. A great gift every day :)

1 0 0 0
Thank you — Matt Godbolt’s blog The end of the 2025 Advent of Compiler Optimisation

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

57 4 4 1
When compilers surprise you — Matt Godbolt’s blog Sometimes compilers can surprise and delight even a jaded old engineer like me

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

31 4 3 1

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

22 2 0 0
Clever memory tricks — Matt Godbolt’s blog We learn that compilers have tricks to access memory efficiently

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

24 4 0 0

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 :-)

49 0 2 0
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 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

22 3 2 0

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

26 4 1 0
Chasing your tail — Matt Godbolt’s blog The art of not (directly) coming back: tail call optimisation

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

24 3 2 0
Partial inlining — Matt Godbolt’s blog Inlining doesn't have to be all-or-nothing

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

26 4 0 1
Inlining - the ultimate optimisation — Matt Godbolt’s blog Copy paste can sometimes be a good thing, at least if the compiler does it for you

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

19 3 0 0
Calling all arguments — Matt Godbolt’s blog Knowing how compilers call functions can help with design - and optimisation

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

42 5 2 0
Aliasing — Matt Godbolt’s blog Knowing when the compiler can't optimise is important too

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

27 4 0 0
When LICM fails us — Matt Godbolt’s blog When aliasing can prevent loop-invariant code motion

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

28 4 1 0

Passed the halfway point of the #AoCO2025 (!!) where has the time gone?!

21 0 3 0
Loop-Invariant Code Motion — Matt Godbolt’s blog The compiler can move code outside of loops to speed things up

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

16 3 0 0
Unswitching loops for fun and profit — Matt Godbolt’s blog Duplicating loops around can yield some decent optimisations

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

24 3 0 1

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

29 5 2 1

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 :-)

43 2 2 0
Unrolling loops — Matt Godbolt’s blog Learning when the compiler decides to unroll loops for performance

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

24 5 1 0
Induction variables and loops — Matt Godbolt’s blog Compilers can rewrite loops to avoid expensive calculations

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

31 6 1 1
Going loopy — Matt Godbolt’s blog Exploring the ways optimisers deal with loop constructs

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

30 11 1 0
Multiplying our way out of division — Matt Godbolt’s blog How compilers avoid expensive division with multiplication tricks

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

34 7 0 1
Division — Matt Godbolt’s blog Division doesn't have to be slow with some clever tricks

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

35 11 1 0