[LLVMdev] Why is there no ashl/lshl?
baldrick at free.fr
Tue May 7 01:05:05 PDT 2013
>> There is a distinction between logical/arithmetic shift right, but why
>> not for shift left?
> The arithmetic right shift has the nice property that it preserves the
> fact that x >> 1 == x/2 for negative signed numbers (unlike the
> logical shift).
except when x is -1.
That said, this is correct: the reason for distinct signed and unsigned
right shifts is basically the same reason we have signed and unsigned
The reason that we don't have distinct signed and unsigned left shift
operators is the same reason we don't have signed and unsigned multiplication
More information about the llvm-dev