[commit: packages/integer-simple] master: Comparison primops return Int# (Fixes #6135) (7f25039)

git at git.haskell.org git at git.haskell.org
Wed Aug 14 17:17:03 CEST 2013


Repository : ssh://git@git.haskell.org/integer-simple

On branch  : master
Link       : http://git.haskell.org/?p=packages/integer-simple.git;a=commit;h=7f250398f96d13c70d0e790c0bf2fd6c7f26bba5

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

commit 7f250398f96d13c70d0e790c0bf2fd6c7f26bba5
Author: Jan Stolarek <jan.stolarek at p.lodz.pl>
Date:   Thu May 16 15:09:53 2013 +0200

    Comparison primops return Int# (Fixes #6135)
    
    For a deatiled discussion of this changes please visit the wiki page:
    http://hackage.haskell.org/trac/ghc/wiki/PrimBool


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

7f250398f96d13c70d0e790c0bf2fd6c7f26bba5
 GHC/Integer.hs                      |    2 +
 GHC/Integer/Logarithms/Internals.hs |    1 +
 GHC/Integer/Type.hs                 |   83 +++++++++++++++++++++--------------
 3 files changed, 53 insertions(+), 33 deletions(-)

diff --git a/GHC/Integer.hs b/GHC/Integer.hs
index 2128ddc..f419b2f 100644
--- a/GHC/Integer.hs
+++ b/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/GHC/Integer/Logarithms/Internals.hs b/GHC/Integer/Logarithms/Internals.hs
index 3e3fbb1..baf0afa 100644
--- a/GHC/Integer/Logarithms/Internals.hs
+++ b/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/GHC/Integer/Type.hs b/GHC/Integer/Type.hs
index f87f1c3..703301c 100644
--- a/GHC/Integer/Type.hs
+++ b/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





More information about the ghc-commits mailing list