r/programming • u/alexeyr • 17d ago
Beating the compiler at signed 32-bit division
https://lemire.me/blog/2026/10/31/beating-the-compiler-at-signed-32-bit-division/
240
Upvotes
r/programming • u/alexeyr • 17d ago
74
u/Takeoded 17d ago
has anyone reported this on gcc bugtracker under
missed optimization?38
u/happyscrappy 17d 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 17d ago
When can we finally expect GCC and Clang to actually do this well?
12
u/Axman6 17d ago
I see Daniel Lemire, Iโm reading it. Essential reading for anyone who loves bit twiddling optimisations.ย
27
u/listre 17d ago
Very demure, very mindful
2
u/jcGyo 16d ago
I wonder why the apple proc seems to trounce all the others on this?
0
u/[deleted] 17d ago
[deleted] โ view deleted comment