diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2014-11-22 13:28:25 +0100 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2014-11-22 13:28:25 +0100 |
commit | 5ea3ee02c7e616235508f1829f8ccfd6047eaf98 (patch) | |
tree | ee2e17ff99903d55442ea44ab522b0744bb0f6de /libraries/base/GHC/Real.hs | |
parent | 2b71b355fb1eb559243444f2dc4584e591fddee1 (diff) | |
download | haskell-5ea3ee02c7e616235508f1829f8ccfd6047eaf98.tar.gz |
Add gcd/Word RULE-based optimisation
This makes use of the `gcdWord` primitive provided by
be7fb7e58c70cd9b0a933fb26cd5f2607d6dc4b2 which should make the
`Word`-variant of `gcd` as performant as the `Int`-variant.
Diffstat (limited to 'libraries/base/GHC/Real.hs')
-rw-r--r-- | libraries/base/GHC/Real.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libraries/base/GHC/Real.hs b/libraries/base/GHC/Real.hs index a5a35db8d2..c3013256c1 100644 --- a/libraries/base/GHC/Real.hs +++ b/libraries/base/GHC/Real.hs @@ -634,6 +634,15 @@ lcm x y = abs ((x `quot` (gcd x y)) * y) gcdInt' :: Int -> Int -> Int gcdInt' (I# x) (I# y) = I# (gcdInt x y) + +#if MIN_VERSION_integer_gmp(1,0,0) +{-# RULES +"gcd/Word->Word->Word" gcd = gcdWord' + #-} + +gcdWord' :: Word -> Word -> Word +gcdWord' (W# x) (W# y) = W# (gcdWord x y) +#endif #endif integralEnumFrom :: (Integral a, Bounded a) => a -> [a] |