[Git][ghc/ghc][master] Bignum: make GMP's bignat_add not recursive

Marge Bot gitlab at gitlab.haskell.org
Tue Nov 3 22:43:11 UTC 2020



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
bff74de7 by Sylvain Henry at 2020-11-03T17:43:03-05:00
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.

- - - - -


1 changed file:

- libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs


Changes:

=====================================
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



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bff74de713dac3e62c3bb6f1946e0649549f2215

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bff74de713dac3e62c3bb6f1946e0649549f2215
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20201103/09b6566d/attachment.html>


More information about the ghc-commits mailing list