summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-06-22 10:47:29 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-07-19 19:36:37 -0400
commite5a4cfa51899e67db8fb17409660107b821d252d (patch)
treedde5c2e380b53bd8d41432943881a7f0bdddcc91
parent5b187575dac64e0a202f0700bdb7a1d1604f9438 (diff)
downloadhaskell-e5a4cfa51899e67db8fb17409660107b821d252d.tar.gz
Bignum: don't allocate in bignat_mul (#20028)
We allocated the recursively entered `mul` helper function because it captures some args.
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs b/libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs
index ee031178bd..723096544a 100644
--- a/libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs
@@ -182,8 +182,8 @@ bignat_mul mwa wa wb s1 =
!ctzB = word2Int# (bigNatCtzWord# wb)
-- multiply a single bj Word# to the whole wa WordArray
- mul bj j i carry s
- | isTrue# (i ==# szA)
+ mul mwa wa bj j i carry s
+ | isTrue# (i ==# wordArraySize# wa)
-- write the carry
= mwaAddInplaceWord# mwa (i +# j) carry s
@@ -193,7 +193,7 @@ bignat_mul mwa wa wb s1 =
!(# c'',r #) = plusWord2# r' carry
carry' = plusWord# c' c''
in case mwaAddInplaceWord# mwa (i +# j) r s of
- s' -> mul bj j (i +# 1#) carry' s'
+ s' -> mul mwa wa bj j (i +# 1#) carry' s'
-- for each bj in wb, call `mul bj wa`
mulEachB i s
@@ -201,7 +201,7 @@ bignat_mul mwa wa wb s1 =
| True = case indexWordArray# wb i of
-- detect bj == 0## and skip the loop
0## -> mulEachB (i +# 1#) s
- bi -> case mul bi i ctzA 0## s of
+ bi -> case mul mwa wa bi i ctzA 0## s of
s' -> mulEachB (i +# 1#) s'
bignat_sub