News for hackers. Stuff that matters.
Re:Why is this C++ code faster than my hand-written assembly... by besselheim on Tuesday August 22, 2017 @11:58AM (#15073656)
Assuming 32-bit unsigned integers (but similarly for other integer sizes), multiplying by 0x11111111 and shifting right 28 bits would give a function of period 15, at least for inputs between 1 and 0x1000000e inclusive. Faster than dividing by 15.
Re:Why is this C++ code faster than my hand-written assembly... by raphlinus on Tuesday August 22, 2017 @12:06PM (#15073742)
You're absolutely on the right track with a (wrapping) multiply and a shift right, but the constants aren't quite right.