Day 8 of Advent of Compiler Optimisations!

Which loop style is fastest—index-based for, pointer while, range-for, or std::accumulate? I compared four different ways to sum a vector. The compiler generates identical assembly for three of them! But one approach forces an extra calculation. Can you guess which? 🔄

Read more: xania.org/202512/08-going-loopy
Watch: youtu.be/FB8Hgj3TpJM

0

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