4 ms·
the author happily used BSF and BTC in the hottest part of the loop... which are actually rather slow instructions Depends on the hardware you're running on. T
by gcp 9y ago
the author happily used BSF and BTC in the hottest part of the loop... which are actually rather slow instructions
Depends on the hardware you're running on. They used to be very fast on Intel machines. (There's an argument here that C survives architecture changes better than the ASM alternative, but BSF/BSR don't have C equivalents that the compiler can translate if appropriate, AFAIK. The best generic, widely fast implementation I know of uses multiply-shift with de Bruijn sequences and isn't automatically translated for obvious reasons)
- bluGill 9y agoThat is the point: I can spend a couple months hand optimizing a hot spot, but for what CPU? The optimizations I'd do for an intel core i7 are different and intel core i9 - and these are generations of the same architecture try to support AMD ryzen and things are very different. Now add in an ARM CPU (which?)... If I can find a better algorithm I can of course beat the compiler on all of the above. However does such an algorithm exist?