Possibly. I tend to trust GHC's strictness analyzer until proven otherwise, though. Feel free to optimize as necessary.

  - Clark


On Wed, Dec 12, 2012 at 3:06 PM, Vo Minh Thu <noteed@gmail.com> wrote:
2012/12/12 Johan Tibell <johan.tibell@gmail.com>:
> On Wed, Dec 12, 2012 at 10:40 AM, Clark Gaebel <cgaebel@uwaterloo.ca> wrote:
>> I just did a quick derivation from
>> http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 to get
>> the highest bit mask, and did not reference FXT nor the containers
>> implementation. Here is my code:
>>
>> highestBitMask :: Word64 -> Word64
>> highestBitMask x1 = let x2 = x1 .|. x1 `shiftR` 1
>>                         x3 = x2 .|. x2 `shiftR` 2
>>                         x4 = x3 .|. x3 `shiftR` 4
>>                         x5 = x4 .|. x4 `shiftR` 8
>>                         x6 = x5 .|. x5 `shiftR` 16
>>                         x7 = x6 .|. x6 `shiftR` 32
>>                      in x7 `xor` (x7 `shiftR` 1)
>>
>> This code is hereby released into the public domain. Problem solved.
>
> I will integrate this into containers later today.

Note that I think the current implementation use a series of case
expression instead of a let binding, possibly to force the evaluation.