r/programming • u/alexeyr • 27d ago
Beating the compiler at signed 32-bit division
https://lemire.me/blog/2026/10/31/beating-the-compiler-at-signed-32-bit-division/
241
Upvotes
r/programming • u/alexeyr • 27d ago
74
u/Takeoded 27d ago
has anyone reported this on gcc bugtracker under
missed optimization?38
u/happyscrappy 27d ago
Seems a suitable wrap-up to "division by multiplying week" on /r/programming.
I can't see why not to use this sequence. Seems to keep the same 30 bits of result. Might be slower on some processors that implement 64 bit mults differently? I don't think that's really the reason just spitballing.
49
u/Sopel97 27d ago
When can we finally expect GCC and Clang to actually do this well?
13
u/Axman6 27d ago
I see Daniel Lemire, Iโm reading it. Essential reading for anyone who loves bit twiddling optimisations.ย
28
u/listre 27d ago
Very demure, very mindful
2
u/jcGyo 26d ago
I wonder why the apple proc seems to trounce all the others on this?
0
u/[deleted] 27d ago
[deleted] โ view deleted comment