summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-10-27 19:12:53 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-29 16:58:35 -0400
commitc8d89f62a32f05bb2f7aa9a8edda4651301cb76f (patch)
treee8dc5a5d6b1d2eefb3ee053855caabbfa1467acf
parentb0a1ed5579a7e80b744d16b0d78d4968284787d9 (diff)
downloadhaskell-c8d89f62a32f05bb2f7aa9a8edda4651301cb76f.tar.gz
Bignum: add missing rule
Add missing "Natural -> Integer -> Word#" rule.
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/Integer.hs3
-rw-r--r--testsuite/tests/numeric/should_compile/T15547.stderr28
2 files changed, 14 insertions, 17 deletions
diff --git a/libraries/ghc-bignum/src/GHC/Num/Integer.hs b/libraries/ghc-bignum/src/GHC/Num/Integer.hs
index 2c8da3dcc6..e2a020619e 100644
--- a/libraries/ghc-bignum/src/GHC/Num/Integer.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/Integer.hs
@@ -1466,6 +1466,9 @@ to only rely on rewrite rules for bignum functions.
"Natural -> Integer -> Natural (clamp)"
forall x. integerToNaturalClamp (integerFromNatural x) = x
+"Natural -> Integer -> Word#"
+ forall x. integerToWord# (integerFromNatural x) = naturalToWord# x
+
"Int# -> Integer -> Word#"
forall x. integerToWord# (IS x) = int2Word# x
diff --git a/testsuite/tests/numeric/should_compile/T15547.stderr b/testsuite/tests/numeric/should_compile/T15547.stderr
index f7eea977bd..e9dfbd0621 100644
--- a/testsuite/tests/numeric/should_compile/T15547.stderr
+++ b/testsuite/tests/numeric/should_compile/T15547.stderr
@@ -1,41 +1,35 @@
==================== Tidy Core ====================
Result size of Tidy Core
- = {terms: 40, types: 100, coercions: 56, joins: 0/0}
+ = {terms: 36, types: 100, coercions: 56, joins: 0/0}
nat2Word#
= \ @n $dKnownNat _ ->
- integerToWord#
- (integerFromNatural
- ($dKnownNat `cast` <Co:5> :: KnownNat n ~R# Natural))
+ naturalToWord# ($dKnownNat `cast` <Co:5> :: KnownNat n ~R# Natural)
foo = \ _ -> 18##
fd
= \ @n $dKnownNat _ ->
- integerToWord#
- (integerFromNatural
- ($dKnownNat
- `cast` <Co:13> :: KnownNat (Div (n + 63) 64) ~R# Natural))
+ naturalToWord#
+ ($dKnownNat
+ `cast` <Co:13> :: KnownNat (Div (n + 63) 64) ~R# Natural)
d = \ _ -> 3##
fm
= \ @n $dKnownNat _ ->
- integerToWord#
- (integerFromNatural
- ($dKnownNat
- `cast` <Co:17> :: KnownNat (Mod (n - 1) 64 + 1) ~R# Natural))
+ naturalToWord#
+ ($dKnownNat
+ `cast` <Co:17> :: KnownNat (Mod (n - 1) 64 + 1) ~R# Natural)
m = \ _ -> 9##
fp
= \ @n $dKnownNat _ ->
- integerToWord#
- (integerFromNatural
- ($dKnownNat
- `cast` <Co:21> :: KnownNat (2 ^ (Mod (n + 63) 64 + 1))
- ~R# Natural))
+ naturalToWord#
+ ($dKnownNat
+ `cast` <Co:21> :: KnownNat (2 ^ (Mod (n + 63) 64 + 1)) ~R# Natural)
p = \ _ -> 512##