r/programming • u/DataBaeBee • Sep 14 '26
How GCC Eliminates Unnecessary Integer Division
https://leetarxiv.substack.com/p/how-gcc-eliminates-unnecessary-integer
251
Upvotes
r/programming • u/DataBaeBee • Sep 14 '26
View all comments
Show parent comment
32
u/ascii Sep 14 '26
Integer division is still not pipelined and 64 bit division takes ~80 cycles on Skylake, which is still a very common architecture out there in the real world. Skylake derived CPUs only stopped being manufactured at the end of 2024.
That said, Arrow lake and Zen 5 idiv use partial pipelining (new instruction every 4-6 cycles) and have cut latencies down to 10-15 cycles.
imul obviously does not take only one cycle, but because it's fully pipelined, it effectively takes one cycle in the right context.
Overall, parent isn't too far off.