summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/Float.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-08-11 16:20:53 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-09-07 08:02:28 -0400
commitf72aa31d36f4fbab0258cae1c94ac0cc24682ab9 (patch)
treebfdd65d170c425272f066a851b26bec3bdf34d96 /libraries/base/GHC/Float.hs
parent3fb1afea019422292954785575902c62473e93e3 (diff)
downloadhaskell-f72aa31d36f4fbab0258cae1c94ac0cc24682ab9.tar.gz
Bignum: refactor conversion rules
* make "passthrough" rules non built-in: they don't need to * enhance note about efficient conversions between numeric types * make integerFromNatural a little more efficient * fix noinline pragma for naturalToWordClamp# (at least with non built-in rules, we get warnings in cases like this)
Diffstat (limited to 'libraries/base/GHC/Float.hs')
-rw-r--r--libraries/base/GHC/Float.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/libraries/base/GHC/Float.hs b/libraries/base/GHC/Float.hs
index da4d14a669..743da55df8 100644
--- a/libraries/base/GHC/Float.hs
+++ b/libraries/base/GHC/Float.hs
@@ -1587,3 +1587,29 @@ foreign import prim "stg_doubleToWord64zh"
#else
stgDoubleToWord64 :: Double# -> Word64#
#endif
+
+
+
+-- See Note [Optimising conversions between numeric types]
+-- in GHC.Num.Integer
+{-# RULES
+
+"Int# -> Integer -> Float#"
+ forall x. integerToFloat# (IS x) = int2Float# x
+
+"Int# -> Integer -> Double#"
+ forall x. integerToDouble# (IS x) = int2Double# x
+
+"Word# -> Integer -> Float#"
+ forall x. integerToFloat# (integerFromWord# x) = word2Float# x
+
+"Word# -> Integer -> Double#"
+ forall x. integerToDouble# (integerFromWord# x) = word2Double# x
+
+"Word# -> Natural -> Float#"
+ forall x. naturalToFloat# (NS x) = word2Float# x
+
+"Word# -> Natural -> Double#"
+ forall x. naturalToDouble# (NS x) = word2Double# x
+
+#-}