-
Notifications
You must be signed in to change notification settings - Fork 181
Use unsafeShift in BitUtil for base >= 4.8 #216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The comments accompanying those indicate the purpose is to ensure inlining.
|
Of course, it's possible that's not necessary, but it would be good to be
|
You're right. It doesn't seem to inline those … I don't understand why shiftRL2 :: Word -> Int -> Word
…
shiftRL2 =
\ (ds_d1VQ :: Word) (ds1_d1VR :: Int) ->
case ds_d1VQ of _ [Occ=Dead] { W# x_a1MJ ->
case ds1_d1VR of _ [Occ=Dead] { I# i_a1MK ->
GHC.Types.W# (uncheckedShiftRL# x_a1MJ i_a1MK)
}
}
shiftRL :: Word -> Int -> Word
…
shiftRL = Data.Bits.$fBitsWord_$cunsafeShiftR |
The comment in |
https://ghc.haskell.org/trac/ghc/ticket/12022 |
There doesn't appear to be any updates on the upstream ticktet and the Bits instance for Int in base-4.10.0.0 still doesn't have unsafeShiftL and unsafeShiftR marked INLINE. I'll follow up on the trac ticket when I get a chance. |
See updated comments in https://ghc.haskell.org/trac/ghc/ticket/12022. It sounds like the advice is still to let the compiler determine when to INLINE. mpickering also points out that the I don't know enough about optimization or GHC semantics at this point to comment on what we should do here. |
I think this can be closed. Today we have
|
Use
unsafeShiftL/R
inBitUtil
for base >= 4.8 instead of explicitly using GHC primitives, and also avoid the warning aboutTrustworthy
.