
16 Aug
2011
16 Aug
'11
10:39 a.m.
On Tue, Aug 16, 2011 at 4:06 PM, Simon Marlow
I've talked this through with Johan, and we came to the conclusion that while "unsafeShiftL" is a bit unsightly, this is the most workable solution. For example, optimising away the test in shiftL directly in the backend is not possible when compiling via LLVM, which only provides the unsafe operation as a primitive.
In fact it's not even possible on plain x86, as the CPU masks out the last 5 bits in the shift amount and only uses those when shifting (i.e. the shift amount is always mod 32). There's no way to optimize away the branch used in `shiftL` and the rest for shifts of unknown size. Johan