Skip to content
  • rwbarton's avatar
    Add MO_AddIntC, MO_SubIntC MachOps and implement in X86 backend · cfd08a99
    rwbarton authored
    Summary:
    These MachOps are used by addIntC# and subIntC#, which in turn are
    used in integer-gmp when adding or subtracting small Integers. The
    following benchmark shows a ~6% speedup after this commit on x86_64
    (building GHC with BuildFlavour=perf).
    
        {-# LANGUAGE MagicHash #-}
    
        import GHC.Exts
        import Criterion.Main
    
        count :: Int -> Integer
        count (I# n#) = go n# 0
          where go :: Int# -> Integer -> Integer
                go 0# acc = acc
                go n# acc = go (n# -# 1#) $! acc + 1
    
        main = defaultMain [bgroup "count"
                              [bench "100" $ whnf count 100]]
    
    Differential Revision: https://phabricator.haskell.org/D140
    cfd08a99