|
|
|
|
|
by einmaliger
3262 days ago
|
|
My x86-assembly has become very rusty, but couldn't it work like this, not using a branch: (with eax being the unsigned 32-bit input word) xor ebx, ebx
test al, 7
stnz bl
shr eax, 3
add eax, ebx
(edit: replaced a movzx with an xor) |
|
But clever compiler still give me the willies, with their less-than-literal interpretations of the meaning of what I wrote.
I prefer code that is efficient good (whether that means fast, or something else appropriate to the circumstance) when taken literally, and then trust trust the compiler to smooth over my naivity about what efficiency really means.