All the values are divisible by 8, so it could do it like this:
cmp eax,40
ja <return 0>
test eax,7
jnz <return 0>
jmp JumpTable[rax]All the values are divisible by 8, so it could do it like this:
cmp eax,40
ja <return 0>
test eax,7
jnz <return 0>
jmp JumpTable[rax]
Okay. Good point, that is quite a bit shorter than I first thought of
A rough benchmark of a version of that against the original shows it to be close to twice as fast for unpredictable input with GCC (4.5 ns vs 2.72 ns) on my old machine. With predictable input where x values often are the same the original version is quicker