summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Jakobi <simon.jakobi@gmail.com>2022-03-10 00:51:03 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-03-11 20:01:11 -0500
commite40cf4ef6cab8e02fcd34efdf98f1715bfa7315c (patch)
tree2c12c90323ebd9d5755a4a811b574f798e8e2e3e
parent5932247cda7a782a3d1325b9715095a7d25e8571 (diff)
downloadhaskell-e40cf4ef6cab8e02fcd34efdf98f1715bfa7315c.tar.gz
ghc-bignum: Tweak integerOr
The result of ORing two BigNats is always greater or equal to the larger of the two. Therefore it is safe to skip the magnitude checks of integerFromBigNat#.
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/Integer.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/libraries/ghc-bignum/src/GHC/Num/Integer.hs b/libraries/ghc-bignum/src/GHC/Num/Integer.hs
index 810ce7f050..419aecf841 100644
--- a/libraries/ghc-bignum/src/GHC/Num/Integer.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/Integer.hs
@@ -637,7 +637,7 @@ integerOr a b = case a of
IS -1# -> IS -1#
IS y -> IS (orI# x y)
IP y
- | isTrue# (x >=# 0#) -> integerFromBigNat# (bigNatOrWord# y (int2Word# x))
+ | isTrue# (x >=# 0#) -> IP (bigNatOrWord# y (int2Word# x))
| True -> integerFromBigNatNeg#
(bigNatAddWord#
(bigNatAndNot -- use De Morgan's laws
@@ -660,7 +660,7 @@ integerOr a b = case a of
1##)
IP x -> case b of
IS _ -> integerOr b a
- IP y -> integerFromBigNat# (bigNatOr x y)
+ IP y -> IP (bigNatOr x y)
IN y -> integerFromBigNatNeg#
(bigNatAddWord#
(bigNatAndNot -- use De Morgan's laws