Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Division is slow, which is something most programmers don't know. If you can binary AND instead of MOD this can be a huge win.

Multiplication is also very fast, usually one or two cycles on larger chips.



>Division is slow

I wondered if that's really still true, since I haven't done much assembly language programming since PowerPC was new.

Here, it says the M1 has 7-9 cycles latency for division instructions, but throughput of 2 cycles per.

https://dougallj.github.io/applecpu/firestorm-int.html

"The M1 is 10x faster than the Xeon at 64 bit divides. It’s…just wow."

So, given all of the other things that can slow you up, I wonder if it really makes sense to avoid division any more?

(I guess the energy efficient "Icestorm" cores have throughput equal to latency, so it's only the "Firestorm" ones where it's super fast)


You shouldn't assume you're running on the performance cores. Not everyone is writing an app, and even if you are, most of your code will be better off on the efficiency cores.


If you're not concerned enough about performance to run on the performance cores, then why worry about...performance?


They aren't always available because you can't always get what you ask for.


If your compiler doesn't do this for divisors known at compile time, get your money back.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: