sar eax, 0x1f
and eax, 7
add eax, edx
sar eax, 3
You get 4 instructions instead of one because value >> 3 rounds towards negative infinity and value / 8 rounds towards zero.And while this wouldn't apply to C++, in languages with checked arithmetic, the left shift won't necessarily set the overflow flag, so the compiler often can't use it.