Repository : ssh://darcs.haskell.org//srv/darcs/packages/integer-gmp On branch : master
http://hackage.haskell.org/trac/ghc/changeset/a07f118c08ac5fd5923b6e0b2c994f4185121604 >--------------------------------------------------------------- commit a07f118c08ac5fd5923b6e0b2c994f4185121604 Author: Ian Lynagh <[email protected]> Date: Fri Jul 13 19:51:08 2012 +0100 Tweak RULEs; fixes #7041 In particular, the gcd rule now uses smallInteger rather than S#, which means that it actually fires. Also fixed a bug when the result is minBound :: Int. >--------------------------------------------------------------- GHC/Integer/Type.lhs | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-) diff --git a/GHC/Integer/Type.lhs b/GHC/Integer/Type.lhs index be3ebea..a402f37 100644 --- a/GHC/Integer/Type.lhs +++ b/GHC/Integer/Type.lhs @@ -135,11 +135,6 @@ int64ToInteger i = if ((i `leInt64#` intToInt64# 0x7FFFFFFF#) && integerToInt :: Integer -> Int# {-# NOINLINE integerToInt #-} -{-# RULES "integerToInt" forall i. integerToInt (S# i) = i #-} --- Don't inline integerToInt, because it can't do much unless --- it sees a (S# i), and inlining just creates fruitless --- join points. But we do need a RULE to get the constants --- to work right: 1::Int had better optimise to (I# 1)! integerToInt (S# i) = i integerToInt (J# s d) = integer2Int# s d @@ -287,8 +282,10 @@ lcmInteger a b = if a `eqInteger` S# 0# then S# 0# where aa = absInteger a 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 (S# a) (S# b) = S# (gcdInt a b) + gcdInteger (smallInteger a) (smallInteger b) = absInteger (smallInteger (gcdInt a b)) #-} gcdInt :: Int# -> Int# -> Int# gcdInt 0# y = absInt y _______________________________________________ Cvs-libraries mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-libraries
