Adding unsafeShiftL, unsafeShiftR to Data.Bits(Bits)
johan.tibell at gmail.com
Tue Aug 16 16:39:36 CEST 2011
On Tue, Aug 16, 2011 at 4:06 PM, Simon Marlow <marlowsd at gmail.com> wrote:
> 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
More information about the Libraries