summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2019-10-03 15:17:15 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-10-29 03:46:22 -0400
commit57dc1565e98d7777c5b2783f947ff6dace311ece (patch)
tree4dcc6a8e94e836ef56bb26294878a50194506fac
parent35abbfee8b4298ef7352a3c2341595c774a7244b (diff)
downloadhaskell-57dc1565e98d7777c5b2783f947ff6dace311ece.tar.gz
Use `not#` primitive to implement Word's complement
-rw-r--r--libraries/base/Data/Bits.hs4
1 files changed, 1 insertions, 3 deletions
diff --git a/libraries/base/Data/Bits.hs b/libraries/base/Data/Bits.hs
index 69446f9adc..fd26d4e297 100644
--- a/libraries/base/Data/Bits.hs
+++ b/libraries/base/Data/Bits.hs
@@ -58,7 +58,6 @@ module Data.Bits (
#include "MachDeps.h"
import Data.Maybe
-import GHC.Enum
import GHC.Num
import GHC.Base
import GHC.Real
@@ -495,8 +494,7 @@ instance Bits Word where
(W# x#) .&. (W# y#) = W# (x# `and#` y#)
(W# x#) .|. (W# y#) = W# (x# `or#` y#)
(W# x#) `xor` (W# y#) = W# (x# `xor#` y#)
- complement (W# x#) = W# (x# `xor#` mb#)
- where !(W# mb#) = maxBound
+ complement (W# x#) = W# (not# x#)
(W# x#) `shift` (I# i#)
| isTrue# (i# >=# 0#) = W# (x# `shiftL#` i#)
| otherwise = W# (x# `shiftRL#` negateInt# i#)