diff options
author | Ian Lynagh <igloo@earth.li> | 2012-07-13 20:04:51 +0100 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2012-07-13 20:04:51 +0100 |
commit | e6bc6b7afc6c9718be1aa305c0368499fa920c4b (patch) | |
tree | 5bda8efb68b7d19c115ece0398f39f4d77f2686e /libraries/integer-gmp/GHC/Integer | |
parent | e5629b9ed80dc906bdd18a53cb1450b56db14b11 (diff) | |
download | haskell-e6bc6b7afc6c9718be1aa305c0368499fa920c4b.tar.gz |
Add another gcdInteger rule
This one is better when the result is converted to an Int
Diffstat (limited to 'libraries/integer-gmp/GHC/Integer')
-rw-r--r-- | libraries/integer-gmp/GHC/Integer/Type.lhs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libraries/integer-gmp/GHC/Integer/Type.lhs b/libraries/integer-gmp/GHC/Integer/Type.lhs index a402f37e49..b9d9c3cd65 100644 --- a/libraries/integer-gmp/GHC/Integer/Type.lhs +++ b/libraries/integer-gmp/GHC/Integer/Type.lhs @@ -283,9 +283,14 @@ lcmInteger a b = if a `eqInteger` S# 0# then S# 0# ab = absInteger b -- This rule needs to use absInteger so that it works correctly when --- the result is minBound :: Int -{-# RULES "gcdInteger/Int" forall a b. - gcdInteger (smallInteger a) (smallInteger b) = absInteger (smallInteger (gcdInt a b)) +-- the result is minBound :: Int. But that isn't necessary when the +-- result is converted to an Int. +{-# RULES +"gcdInteger/Int" forall a b. + gcdInteger (smallInteger a) (smallInteger b) + = absInteger (smallInteger (gcdInt a b)) +"integerToInt/gcdInteger/Int" forall a b. + integerToInt (gcdInteger (smallInteger a) (smallInteger b)) = gcdInt a b #-} gcdInt :: Int# -> Int# -> Int# gcdInt 0# y = absInt y |