[commit: packages/base] master: Workaround failed constant-folding for zeroBits (2dbfcd7)
git at git.haskell.org
git at git.haskell.org
Sat Mar 1 13:52:53 UTC 2014
Repository : ssh://git@git.haskell.org/base
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/2dbfcd70e53845d9119389cecc88411b47b70644/base
>---------------------------------------------------------------
commit 2dbfcd70e53845d9119389cecc88411b47b70644
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date: Sat Mar 1 14:45:48 2014 +0100
Workaround failed constant-folding for zeroBits
For some reason GHC fails to constant fold `zeroBits :: Int` and
`zeroBits :: Integer`; `ghc -show-iface` shows
$fBitsInt_$czeroBits :: GHC.Types.Int
{- Strictness: m,
Unfolding: (GHC.Types.I# (GHC.Prim.andI# 1 (GHC.Prim.notI# 1))) -}
Otoh, constant-folding works as expected, reducing `zeroBits` to 0 constant
for the other integer-types (= {Word,Int}{8,16,32,64}` and `Word`). So this
quickfix is actually just treating the symptom rather than the cause.
Signed-off-by: Herbert Valerio Riedel <hvr at gnu.org>
>---------------------------------------------------------------
2dbfcd70e53845d9119389cecc88411b47b70644
Data/Bits.hs | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Data/Bits.hs b/Data/Bits.hs
index e771624..28cd024 100644
--- a/Data/Bits.hs
+++ b/Data/Bits.hs
@@ -363,6 +363,8 @@ instance Bits Int where
{-# INLINE bit #-}
{-# INLINE testBit #-}
+ zeroBits = 0
+
bit = bitDefault
testBit = testBitDefault
@@ -437,6 +439,7 @@ instance Bits Integer where
| otherwise = shiftRInteger x (negateInt# i#)
testBit x (I# i) = testBitInteger x i
+ zeroBits = 0
bit = bitDefault
popCount = popCountDefault
More information about the ghc-commits
mailing list