Day 10 of Advent of Compiler Optimisations!

A simple loop summing 8 values — but tell the compiler the count is fixed at compile time and watch what happens. The code transforms in surprising ways. What does "unrolling" actually look like in assembly, and when does the compiler decide it's worth it? Try changing the count and see how the strategy changes!

Read more: xania.org/202512/10-loop-unrol
Watch: youtu.be/HvF3tF2efEA

0

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