On 1/16/2022 7:08 AM, Mark Dickinson wrote:
Now /that/ I certainly wasn't expecting. I don't see the same effect on macOS / Clang, whether compiling with --enable-optimizations or not; this appears to be a GCC innovation. And indeed, as Tim suggested, it turns out that there's no division instruction present in the loop for the division-by-10 case - we're doing division via multiplication by the reciprocal. In Python terms, we're computing `x // 10` as `(x * 0xcccccccccccccccd) >> 67`.
https://stackoverflow.com/questions/41183935/why-does-gcc-use-multiplication... and https://stackoverflow.com/questions/30790184/perform-integer-division-using-... have multiple discussions of the technique for machine division invariant (small) ints and GCC's use thereof (only suppressed with -0s?). -- Terry Jan Reedy