diff options
Diffstat (limited to 'libraries/integer-simple')
-rw-r--r-- | libraries/integer-simple/GHC/Integer.hs | 2 | ||||
-rw-r--r-- | libraries/integer-simple/GHC/Integer/Logarithms/Internals.hs | 1 | ||||
-rw-r--r-- | libraries/integer-simple/GHC/Integer/Type.hs | 83 |
3 files changed, 53 insertions, 33 deletions
diff --git a/libraries/integer-simple/GHC/Integer.hs b/libraries/integer-simple/GHC/Integer.hs index 2128ddc93e..f419b2f592 100644 --- a/libraries/integer-simple/GHC/Integer.hs +++ b/libraries/integer-simple/GHC/Integer.hs @@ -27,6 +27,8 @@ module GHC.Integer ( plusInteger, minusInteger, timesInteger, negateInteger, eqInteger, neqInteger, absInteger, signumInteger, leInteger, gtInteger, ltInteger, geInteger, compareInteger, + eqInteger#, neqInteger#, + leInteger#, gtInteger#, ltInteger#, geInteger#, divInteger, modInteger, divModInteger, quotRemInteger, quotInteger, remInteger, encodeFloatInteger, decodeFloatInteger, floatFromInteger, diff --git a/libraries/integer-simple/GHC/Integer/Logarithms/Internals.hs b/libraries/integer-simple/GHC/Integer/Logarithms/Internals.hs index 3e3fbb1ee5..baf0afa575 100644 --- a/libraries/integer-simple/GHC/Integer/Logarithms/Internals.hs +++ b/libraries/integer-simple/GHC/Integer/Logarithms/Internals.hs @@ -18,6 +18,7 @@ module GHC.Integer.Logarithms.Internals ) where import GHC.Prim +import GHC.PrimWrappers import GHC.Integer.Type default () diff --git a/libraries/integer-simple/GHC/Integer/Type.hs b/libraries/integer-simple/GHC/Integer/Type.hs index f87f1c314f..703301c181 100644 --- a/libraries/integer-simple/GHC/Integer/Type.hs +++ b/libraries/integer-simple/GHC/Integer/Type.hs @@ -23,6 +23,7 @@ module GHC.Integer.Type where import GHC.Prim +import GHC.PrimWrappers import GHC.Classes import GHC.Types import GHC.Tuple () @@ -424,45 +425,61 @@ Naught `compareInteger` Negative _ = GT Negative x `compareInteger` Negative y = y `comparePositive` x (!_) `compareInteger` (!_) = LT -{-# NOINLINE eqInteger #-} -eqInteger :: Integer -> Integer -> Bool -x `eqInteger` y = case x `compareInteger` y of - EQ -> True - _ -> False +{-# NOINLINE eqInteger# #-} +eqInteger# :: Integer -> Integer -> Int# +x `eqInteger#` y = case x `compareInteger` y of + EQ -> 1# + _ -> 0# -{-# NOINLINE neqInteger #-} -neqInteger :: Integer -> Integer -> Bool -x `neqInteger` y = case x `compareInteger` y of - EQ -> False - _ -> True +{-# NOINLINE neqInteger# #-} +neqInteger# :: Integer -> Integer -> Int# +x `neqInteger#` y = case x `compareInteger` y of + EQ -> 0# + _ -> 1# + +{-# INLINE eqInteger #-} +{-# INLINE neqInteger #-} +eqInteger, neqInteger :: Integer -> Integer -> Bool +eqInteger a b = tagToEnum# (a `eqInteger#` b) +neqInteger a b = tagToEnum# (a `neqInteger#` b) instance Eq Integer where (==) = eqInteger (/=) = neqInteger -{-# NOINLINE ltInteger #-} -ltInteger :: Integer -> Integer -> Bool -x `ltInteger` y = case x `compareInteger` y of - LT -> True - _ -> False - -{-# NOINLINE gtInteger #-} -gtInteger :: Integer -> Integer -> Bool -x `gtInteger` y = case x `compareInteger` y of - GT -> True - _ -> False - -{-# NOINLINE leInteger #-} -leInteger :: Integer -> Integer -> Bool -x `leInteger` y = case x `compareInteger` y of - GT -> False - _ -> True - -{-# NOINLINE geInteger #-} -geInteger :: Integer -> Integer -> Bool -x `geInteger` y = case x `compareInteger` y of - LT -> False - _ -> True +{-# NOINLINE ltInteger# #-} +ltInteger# :: Integer -> Integer -> Int# +x `ltInteger#` y = case x `compareInteger` y of + LT -> 1# + _ -> 0# + +{-# NOINLINE gtInteger# #-} +gtInteger# :: Integer -> Integer -> Int# +x `gtInteger#` y = case x `compareInteger` y of + GT -> 1# + _ -> 0# + +{-# NOINLINE leInteger# #-} +leInteger# :: Integer -> Integer -> Int# +x `leInteger#` y = case x `compareInteger` y of + GT -> 0# + _ -> 1# + +{-# NOINLINE geInteger# #-} +geInteger# :: Integer -> Integer -> Int# +x `geInteger#` y = case x `compareInteger` y of + LT -> 0# + _ -> 1# + +{-# INLINE leInteger #-} +{-# INLINE ltInteger #-} +{-# INLINE geInteger #-} +{-# INLINE gtInteger #-} +leInteger, gtInteger, ltInteger, geInteger :: Integer -> Integer -> Bool +leInteger a b = tagToEnum# (a `leInteger#` b) +gtInteger a b = tagToEnum# (a `gtInteger#` b) +ltInteger a b = tagToEnum# (a `ltInteger#` b) +geInteger a b = tagToEnum# (a `geInteger#` b) instance Ord Integer where (<=) = leInteger |