File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed
Utils/Containers/Internal Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,8 @@ mask i m = i .&. ((-m) `xor` m)
150150{-# INLINE mask #-}
151151
152152-- | The first switching bit where the two prefixes disagree.
153+ --
154+ -- Precondition for defined behavior: p1 /= p2
153155branchMask :: Int -> Int -> Int
154156branchMask p1 p2 = iHighestBitMask (p1 `xor` p2)
155157{-# INLINE branchMask #-}
Original file line number Diff line number Diff line change @@ -44,11 +44,15 @@ import GHC.Exts (Int(..), uncheckedIShiftRL#)
4444#endif
4545
4646-- | An @Int@ where only the highest bit is set.
47+ --
48+ -- Precondition for defined behavior: w /= 0
4749iHighestBitMask :: Int -> Int
4850iHighestBitMask w = unsafeShiftL 1 (wordSize - 1 - countLeadingZeros w)
4951{-# INLINE iHighestBitMask #-}
5052
5153-- Right and left logical shifts.
54+ --
55+ -- Precondition for defined behavior: 0 <= shift amount < wordSize
5256shiftRL , shiftLL :: Word -> Int -> Word
5357shiftRL = unsafeShiftR
5458shiftLL = unsafeShiftL
@@ -58,6 +62,8 @@ wordSize :: Int
5862wordSize = finiteBitSize (0 :: Word )
5963
6064-- Right logical shift.
65+ --
66+ -- Precondition for defined behavior: 0 <= shift amount < wordSize
6167iShiftRL :: Int -> Int -> Int
6268#ifdef __GLASGOW_HASKELL__
6369iShiftRL (I # x# ) (I # sh# ) = I # (uncheckedIShiftRL# x# sh# )
You can’t perform that action at this time.
0 commit comments