Clang knows what’s up: https://godbolt.org/z/7zKffz. GCC is adding the numbers four at a time by stuffing 0, 1, 2, 3 in an XMM register, taking a packed addition within the register, and then doing a pairwise packed addition of the register with 4, 4, 4, 4 to get the next four numbers.
gcc and clang both perform this optimization for me at -O3.
Thanks. On godbolt, I see clang do it at -O3. But gcc still has a loop, where the body has add but no mul, although I don't fully understand the body. Where do you see it in gcc?