Day 9 of Advent of Compiler Optimisations!

Loop with `i * i` inside? Surely the compiler replaces that expensive multiply with clever addition tricks — like manually tracking an accumulator. But no! The compiler keeps the multiply because it enables something more valuable. Why is "more expensive per iteration" sometimes faster overall? The answer lies in how modern CPUs actually execute code.

Read more: xania.org/202512/09-induction-
Watch: youtu.be/vZk7Br6Vh1U

0

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