21 ms·
Yes: https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/divide-and-conquer https://community.arm.com/developer/ip-products/pr
by orangecat 7y ago
Yes: https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/divide-and-conquer https://community.arm.com/developer/ip-products/processors/b.... I ran into this several years ago when one of my devices was surprisingly slow with code like "x = (x + 1) % limit". Turns out it didn't do integer division in hardware (the mod operator requires a divide) and was using a runtime library. Replacing the code with "x++; if (x == limit) x = 0;" made it much faster.
- benibela 7y agoI just benchmarked a bunch of hashmaps, and the fastest maps were using a power of 2 as size. So they could do "x = (x + 1) & (limit - 1)". No division and branch free.