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