[commit: ghc] wip/rwbarton-minusInteger: Simplify minusInteger in integer-gmp slightly (ee0889d)

git at git.haskell.org git at git.haskell.org
Fri Jan 27 22:29:16 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/rwbarton-minusInteger
Link       : http://ghc.haskell.org/trac/ghc/changeset/ee0889d596d271b2f6bc2e2d6dce2a443edf1b67/ghc

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

commit ee0889d596d271b2f6bc2e2d6dce2a443edf1b67
Author: Reid Barton <rwbarton at gmail.com>
Date:   Fri Jan 27 17:18:27 2017 -0500

    Simplify minusInteger in integer-gmp slightly
    
    Summary:
    These two special cases were created in D2279 by mechanically
    inlining negateInteger into plusInteger. They aren't needed
    (the `minusInteger (S# x#) (S# y#)` case already handles all values
    correctly), and they can never help by avoiding an allocation,
    unlike the original special case in plusInteger, since we still
    have to allocate the result.
    
    Removing these special cases will save a couple comparisons and
    conditional branches in the common case of subtracting two small
    Integers.
    
    Test Plan:
    Existing test `plusMinusInteger` already tests
    the values in question.
    
    Reviewers: austin, hvr, goldfire, bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D3034


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

ee0889d596d271b2f6bc2e2d6dce2a443edf1b67
 libraries/integer-gmp/src/GHC/Integer/Type.hs | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libraries/integer-gmp/src/GHC/Integer/Type.hs b/libraries/integer-gmp/src/GHC/Integer/Type.hs
index 0d279ef..d5f92b3 100644
--- a/libraries/integer-gmp/src/GHC/Integer/Type.hs
+++ b/libraries/integer-gmp/src/GHC/Integer/Type.hs
@@ -421,8 +421,6 @@ plusInteger (Jp# x) (Jn# y)
 -- | Subtract one 'Integer' from another.
 minusInteger :: Integer -> Integer -> Integer
 minusInteger x       (S# 0#)            = x
-minusInteger (S# 0#) (S# INT_MINBOUND#) = Jp# (wordToBigNat ABS_INT_MINBOUND##)
-minusInteger (S# 0#) (S# y#)            = S# (negateInt# y#)
 minusInteger (S# x#) (S# y#)
   = case subIntC# x# y# of
     (# z#, 0# #) -> S# z#



More information about the ghc-commits mailing list