Day 14 of Advent of Compiler Optimisations! 🎄
Yesterday we saw the compiler beautifully hoist strlen() out of our loop. Today? Add a single global counter and watch that optimisation vanish—strlen gets called EVERY iteration! But why would incrementing an unrelated variable break loop-invariant code motion? The answer involves a surprising rule about char* in the C++ standard.
Read more: https://xania.org/202512/14-licm-when-it-doesnt
Watch: https://youtu.be/OwFNblEEAXo