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: xania.org/202512/14-licm-when-
Watch: youtu.be/OwFNblEEAXo

0

If you have a fediverse account, you can quote this note from your own instance. Search https://hachyderm.io/users/mattgodbolt/statuses/115718085386867851 on your instance and quote it. (Note that quoting is not supported in Mastodon.)