[commit: packages/base] master: Use not# rather than (`xor#` (-1)) for complement (b2dce68)

git at git.haskell.org git at git.haskell.org
Thu Mar 13 12:26:52 UTC 2014


Repository : ssh://git@git.haskell.org/base

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/b2dce687bd5d1f568fa7ef50ee201310ee24fe80/base

>---------------------------------------------------------------

commit b2dce687bd5d1f568fa7ef50ee201310ee24fe80
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Thu Mar 13 12:12:53 2014 +0000

    Use not# rather than (`xor#` (-1)) for complement
    
    I'm not sure why we weren't using not# before; maybe it wasn't
    a primpop at that stage?  Strange.


>---------------------------------------------------------------

b2dce687bd5d1f568fa7ef50ee201310ee24fe80
 GHC/Int.hs |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/GHC/Int.hs b/GHC/Int.hs
index b9a807e..899d9ad 100644
--- a/GHC/Int.hs
+++ b/GHC/Int.hs
@@ -139,7 +139,7 @@ instance Bits Int8 where
     (I8# x#) .&.   (I8# y#)   = I8# (word2Int# (int2Word# x# `and#` int2Word# y#))
     (I8# x#) .|.   (I8# y#)   = I8# (word2Int# (int2Word# x# `or#`  int2Word# y#))
     (I8# x#) `xor` (I8# y#)   = I8# (word2Int# (int2Word# x# `xor#` int2Word# y#))
-    complement (I8# x#)       = I8# (word2Int# (int2Word# x# `xor#` int2Word# (-1#)))
+    complement (I8# x#)       = I8# (word2Int# (not# (int2Word# x#)))
     (I8# x#) `shift` (I# i#)
         | isTrue# (i# >=# 0#) = I8# (narrow8Int# (x# `iShiftL#` i#))
         | otherwise           = I8# (x# `iShiftRA#` negateInt# i#)
@@ -298,7 +298,7 @@ instance Bits Int16 where
     (I16# x#) .&.   (I16# y#)  = I16# (word2Int# (int2Word# x# `and#` int2Word# y#))
     (I16# x#) .|.   (I16# y#)  = I16# (word2Int# (int2Word# x# `or#`  int2Word# y#))
     (I16# x#) `xor` (I16# y#)  = I16# (word2Int# (int2Word# x# `xor#` int2Word# y#))
-    complement (I16# x#)       = I16# (word2Int# (int2Word# x# `xor#` int2Word# (-1#)))
+    complement (I16# x#)       = I16# (word2Int# (not# (int2Word# x#)))
     (I16# x#) `shift` (I# i#)
         | isTrue# (i# >=# 0#)  = I16# (narrow16Int# (x# `iShiftL#` i#))
         | otherwise            = I16# (x# `iShiftRA#` negateInt# i#)
@@ -462,7 +462,7 @@ instance Bits Int32 where
     (I32# x#) .&.   (I32# y#)  = I32# (word2Int# (int2Word# x# `and#` int2Word# y#))
     (I32# x#) .|.   (I32# y#)  = I32# (word2Int# (int2Word# x# `or#`  int2Word# y#))
     (I32# x#) `xor` (I32# y#)  = I32# (word2Int# (int2Word# x# `xor#` int2Word# y#))
-    complement (I32# x#)       = I32# (word2Int# (int2Word# x# `xor#` int2Word# (-1#)))
+    complement (I32# x#)       = I32# (word2Int# (not# (int2Word# x#)))
     (I32# x#) `shift` (I# i#)
         | isTrue# (i# >=# 0#)  = I32# (narrow32Int# (x# `iShiftL#` i#))
         | otherwise            = I32# (x# `iShiftRA#` negateInt# i#)



More information about the ghc-commits mailing list