Day 15 of Advent of Compiler Optimisations!

Two nearly identical loops: one accumulates ints into an int, the other accumulates ints into a long. You'd expect similar assembly—just different register sizes, right? Wrong! One loop writes to memory on every iteration, the other keeps everything in registers. Same algorithm, wildly different performance. What's going on?

Read more: xania.org/202512/15-aliasing-i
Watch: youtu.be/PPJtJzT2U04

0

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