summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-11-02 15:24:38 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-11-03 17:43:03 -0500
commitbff74de713dac3e62c3bb6f1946e0649549f2215 (patch)
tree11dbd1af8ac03d3a2d9fd8320bd31bcaac79b173
parent37f0434d65fa0891a961504c8882893fad7609c6 (diff)
downloadhaskell-bff74de713dac3e62c3bb6f1946e0649549f2215.tar.gz
Bignum: make GMP's bignat_add not recursive
bignat_add was a loopbreaker with an INLINE pragma (spotted by @mpickering). This patch makes it non recursive to avoid the issue.
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs b/libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs
index 8db1dd57b2..649a7acc70 100644
--- a/libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs
@@ -70,13 +70,13 @@ bignat_add
-> State# RealWorld
{-# INLINE bignat_add #-}
bignat_add mwa wa wb s
- -- weird GMP requirement
+ -- weird GMP requirement: the biggest comes first
| isTrue# (wordArraySize# wb ># wordArraySize# wa)
- = bignat_add mwa wb wa s
+ = case ioWord# (c_mpn_add mwa wb (wordArraySize# wb) wa (wordArraySize# wa)) s of
+ (# s', c #) -> mwaWriteMostSignificant mwa c s'
| True
- = do
- case ioWord# (c_mpn_add mwa wa (wordArraySize# wa) wb (wordArraySize# wb)) s of
+ = case ioWord# (c_mpn_add mwa wa (wordArraySize# wa) wb (wordArraySize# wb)) s of
(# s', c #) -> mwaWriteMostSignificant mwa c s'
bignat_add_word