summaryrefslogtreecommitdiff
path: root/testsuite/tests/lib/integer/T18813.hs
blob: 77f598fe7b099d186de4e0946f3dba264a1da4cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MagicHash    #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -O0 #-}

import GHC.Exts
import GHC.Num.BigNat  (bigNatCompareWord#, bigNatFromWord#)
import GHC.Num.Integer (integerGcd)

main :: IO ()
main = do
   let
      x = noinline (14205695611797621937 :: Integer)
      y = noinline (2 :: Word)
   print (integerGcd x (toInteger y))
   print (toInteger (gcd (fromInteger x) y :: Word))

   let
      x@(W# x#) = 1 :: Word
      !x'       = bigNatFromWord# x#
   print (bigNatCompareWord# x' x#)
   print (compare x x)