Commit 380638a3 authored by Sylvain Henry's avatar Sylvain Henry Committed by Marge Bot

Bignum: fix powMod for gmp backend (#18515)

Also reenable integerPowMod test which had never been reenabled by
mistake.
parent 175cb5b4
Pipeline #22872 failed with stages
in 315 minutes and 33 seconds
......@@ -349,7 +349,8 @@ bignat_powmod
-> State# RealWorld
-> State# RealWorld
bignat_powmod r b e m s =
ioVoid (integer_gmp_powm# r b (wordArraySize# b) e (wordArraySize# e) m (wordArraySize# m)) s
case ioInt# (integer_gmp_powm# r b (wordArraySize# b) e (wordArraySize# e) m (wordArraySize# m)) s of
(# s', n #) -> mwaSetSize# r (narrowGmpSize# n) s'
----------------------------------------------------------------------
......
......@@ -5,11 +5,11 @@ test('integerConstantFolding', normal, makefile_test, ['integerConstantFolding']
test('fromToInteger', [], makefile_test, ['fromToInteger'])
test('IntegerConversionRules', [], makefile_test, ['IntegerConversionRules'])
test('gcdInteger', normal, compile_and_run, [''])
test('integerPowMod', [], compile_and_run, [''])
# skip ghci as it doesn't support unboxed tuples
test('integerImportExport', [omit_ways(['ghci'])], compile_and_run, [''])
# Disable GMP only tests
#test('integerGcdExt', [omit_ways(['ghci'])], compile_and_run, [''])
#test('integerPowMod', [], compile_and_run, [''])
#test('integerGmpInternals', [], compile_and_run, [''])
......@@ -7,19 +7,12 @@ import Control.Monad
import GHC.Word
import GHC.Base
import qualified GHC.Integer.GMP.Internals as I
powModSecInteger :: Integer -> Integer -> Integer -> Integer
powModSecInteger = I.powModSecInteger
powModInteger :: Integer -> Integer -> Integer -> Integer
powModInteger = I.powModInteger
import GHC.Natural
main :: IO ()
main = do
print $ powModInteger b e m
print $ powModInteger b e (m-1)
print $ powModSecInteger b e (m-1)
print $ powModNatural b e m
print $ powModNatural b e (m-1)
where
b = 2988348162058574136915891421498819466320163312926952423791023078876139
......
1527229998585248450016808958343740453059
682382427572745901624116300491295556924
682382427572745901624116300491295556924
{-# LANGUAGE MagicHash #-}
import GHC.Num.BigNat
import GHC.Num.Integer
main :: IO ()
main =
let b = integerToBigNatClamp# 251943445928310882947152017889649234
e = integerToBigNatClamp# 503886891856621765894304035779298468
m = integerToBigNatClamp# 503886891856621765894304035779298469
r = integerFromBigNat# (bigNatPowMod b e m)
in print r
......@@ -72,3 +72,4 @@ test('T17303', normal, compile_and_run, [''])
test('T18359', normal, compile_and_run, [''])
test('T18499', normal, compile_and_run, [''])
test('T18509', normal, compile_and_run, [''])
test('T18515', normal, compile_and_run, [''])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment