summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2012-05-21 20:41:51 +0100
committerIan Lynagh <igloo@earth.li>2012-05-21 20:41:51 +0100
commitc06e2a461ad6b095a387e9fe773e61ff8977727a (patch)
tree15940348dc600fc0b2eb5039749973745a24f351
parent5fdb0b5f24cd9486e56c102e1e3bb4c3e11b9eef (diff)
downloadhaskell-c06e2a461ad6b095a387e9fe773e61ff8977727a.tar.gz
Use Word literals directly, rather than converting Int literals
-rw-r--r--libraries/base/GHC/Base.lhs4
-rw-r--r--libraries/base/GHC/Char.hs2
-rw-r--r--libraries/base/GHC/Int.hs10
-rw-r--r--libraries/base/GHC/Word.hs18
4 files changed, 17 insertions, 17 deletions
diff --git a/libraries/base/GHC/Base.lhs b/libraries/base/GHC/Base.lhs
index 2f457a8097..f684563841 100644
--- a/libraries/base/GHC/Base.lhs
+++ b/libraries/base/GHC/Base.lhs
@@ -776,13 +776,13 @@ Similarly for Float (#5178):
-- | Shift the argument left by the specified number of bits
-- (which must be non-negative).
shiftL# :: Word# -> Int# -> Word#
-a `shiftL#` b | b >=# WORD_SIZE_IN_BITS# = int2Word# 0#
+a `shiftL#` b | b >=# WORD_SIZE_IN_BITS# = 0##
| otherwise = a `uncheckedShiftL#` b
-- | Shift the argument right by the specified number of bits
-- (which must be non-negative).
shiftRL# :: Word# -> Int# -> Word#
-a `shiftRL#` b | b >=# WORD_SIZE_IN_BITS# = int2Word# 0#
+a `shiftRL#` b | b >=# WORD_SIZE_IN_BITS# = 0##
| otherwise = a `uncheckedShiftRL#` b
-- | Shift the argument left by the specified number of bits
diff --git a/libraries/base/GHC/Char.hs b/libraries/base/GHC/Char.hs
index 398ff8165c..46661616b3 100644
--- a/libraries/base/GHC/Char.hs
+++ b/libraries/base/GHC/Char.hs
@@ -9,7 +9,7 @@ import GHC.Show
-- | The 'Prelude.toEnum' method restricted to the type 'Data.Char.Char'.
chr :: Int -> Char
chr i@(I# i#)
- | int2Word# i# `leWord#` int2Word# 0x10FFFF# = C# (chr# i#)
+ | int2Word# i# `leWord#` 0x10FFFF## = C# (chr# i#)
| otherwise
= error ("Prelude.chr: bad argument: " ++ showSignedInt (I# 9#) i "")
diff --git a/libraries/base/GHC/Int.hs b/libraries/base/GHC/Int.hs
index a2bcae5df3..21c0f4fd42 100644
--- a/libraries/base/GHC/Int.hs
+++ b/libraries/base/GHC/Int.hs
@@ -155,7 +155,7 @@ instance Bits Int8 where
(x'# `uncheckedShiftRL#` (8# -# i'#)))))
where
!x'# = narrow8Word# (int2Word# x#)
- !i'# = word2Int# (int2Word# i# `and#` int2Word# 7#)
+ !i'# = word2Int# (int2Word# i# `and#` 7##)
bitSize _ = 8
isSigned _ = True
popCount (I8# x#) = I# (word2Int# (popCnt8# (int2Word# x#)))
@@ -310,7 +310,7 @@ instance Bits Int16 where
(x'# `uncheckedShiftRL#` (16# -# i'#)))))
where
!x'# = narrow16Word# (int2Word# x#)
- !i'# = word2Int# (int2Word# i# `and#` int2Word# 15#)
+ !i'# = word2Int# (int2Word# i# `and#` 15##)
bitSize _ = 16
isSigned _ = True
popCount (I16# x#) = I# (word2Int# (popCnt16# (int2Word# x#)))
@@ -471,7 +471,7 @@ instance Bits Int32 where
(x'# `uncheckedShiftRL#` (32# -# i'#)))))
where
!x'# = narrow32Word# (int2Word# x#)
- !i'# = word2Int# (int2Word# i# `and#` int2Word# 31#)
+ !i'# = word2Int# (int2Word# i# `and#` 31##)
bitSize _ = 32
isSigned _ = True
popCount (I32# x#) = I# (word2Int# (popCnt32# (int2Word# x#)))
@@ -661,7 +661,7 @@ instance Bits Int64 where
(x'# `uncheckedShiftRL64#` (64# -# i'#))))
where
!x'# = int64ToWord64# x#
- !i'# = word2Int# (int2Word# i# `and#` int2Word# 63#)
+ !i'# = word2Int# (int2Word# i# `and#` 63##)
bitSize _ = 64
isSigned _ = True
popCount (I64# x#) =
@@ -798,7 +798,7 @@ instance Bits Int64 where
(x'# `uncheckedShiftRL#` (64# -# i'#))))
where
!x'# = int2Word# x#
- !i'# = word2Int# (int2Word# i# `and#` int2Word# 63#)
+ !i'# = word2Int# (int2Word# i# `and#` 63##)
bitSize _ = 64
isSigned _ = True
popCount (I64# x#) = I# (word2Int# (popCnt64# (int2Word# x#)))
diff --git a/libraries/base/GHC/Word.hs b/libraries/base/GHC/Word.hs
index c0d8141632..0dcb0e32f8 100644
--- a/libraries/base/GHC/Word.hs
+++ b/libraries/base/GHC/Word.hs
@@ -124,9 +124,9 @@ instance Bounded Word where
-- use unboxed literals for maxBound, because GHC doesn't optimise
-- (fromInteger 0xffffffff :: Word).
#if WORD_SIZE_IN_BITS == 32
- maxBound = W# (int2Word# 0xFFFFFFFF#)
+ maxBound = W# 0xFFFFFFFF##
#else
- maxBound = W# (int2Word# 0xFFFFFFFFFFFFFFFF#)
+ maxBound = W# 0xFFFFFFFFFFFFFFFF##
#endif
instance Ix Word where
@@ -275,7 +275,7 @@ instance Bits Word8 where
| otherwise = W8# (narrow8Word# ((x# `uncheckedShiftL#` i'#) `or#`
(x# `uncheckedShiftRL#` (8# -# i'#))))
where
- !i'# = word2Int# (int2Word# i# `and#` int2Word# 7#)
+ !i'# = word2Int# (int2Word# i# `and#` 7##)
bitSize _ = 8
isSigned _ = False
popCount (W8# x#) = I# (word2Int# (popCnt8# x#))
@@ -418,7 +418,7 @@ instance Bits Word16 where
| otherwise = W16# (narrow16Word# ((x# `uncheckedShiftL#` i'#) `or#`
(x# `uncheckedShiftRL#` (16# -# i'#))))
where
- !i'# = word2Int# (int2Word# i# `and#` int2Word# 15#)
+ !i'# = word2Int# (int2Word# i# `and#` 15##)
bitSize _ = 16
isSigned _ = False
popCount (W16# x#) = I# (word2Int# (popCnt16# x#))
@@ -602,7 +602,7 @@ instance Bits Word32 where
| otherwise = W32# (narrow32Word# ((x# `uncheckedShiftL#` i'#) `or#`
(x# `uncheckedShiftRL#` (32# -# i'#))))
where
- !i'# = word2Int# (int2Word# i# `and#` int2Word# 31#)
+ !i'# = word2Int# (int2Word# i# `and#` 31##)
bitSize _ = 32
isSigned _ = False
popCount (W32# x#) = I# (word2Int# (popCnt32# x#))
@@ -735,7 +735,7 @@ instance Bits Word64 where
| otherwise = W64# ((x# `uncheckedShiftL64#` i'#) `or64#`
(x# `uncheckedShiftRL64#` (64# -# i'#)))
where
- !i'# = word2Int# (int2Word# i# `and#` int2Word# 63#)
+ !i'# = word2Int# (int2Word# i# `and#` 63##)
bitSize _ = 64
isSigned _ = False
popCount (W64# x#) = I# (word2Int# (popCnt64# x#))
@@ -749,10 +749,10 @@ instance Bits Word64 where
shiftL64#, shiftRL64# :: Word64# -> Int# -> Word64#
-a `shiftL64#` b | b >=# 64# = wordToWord64# (int2Word# 0#)
+a `shiftL64#` b | b >=# 64# = wordToWord64# 0##
| otherwise = a `uncheckedShiftL64#` b
-a `shiftRL64#` b | b >=# 64# = wordToWord64# (int2Word# 0#)
+a `shiftRL64#` b | b >=# 64# = wordToWord64# 0##
| otherwise = a `uncheckedShiftRL64#` b
{-# RULES
@@ -850,7 +850,7 @@ instance Bits Word64 where
| otherwise = W64# ((x# `uncheckedShiftL#` i'#) `or#`
(x# `uncheckedShiftRL#` (64# -# i'#)))
where
- !i'# = word2Int# (int2Word# i# `and#` int2Word# 63#)
+ !i'# = word2Int# (int2Word# i# `and#` 63##)
bitSize _ = 64
isSigned _ = False
popCount (W64# x#) = I# (word2Int# (popCnt64# x#))