summaryrefslogtreecommitdiff
path: root/testsuite/tests/primops
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-10-20 11:39:16 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-11-06 07:53:42 -0400
commit20956e5784fe43781d156dd7ab02f0bff4ab41fb (patch)
treede4776b5223cc3e6c983bd4eec28cbef4f973a8f /testsuite/tests/primops
parent646c3e21dd30a2eaae46aafb8678d29f8e06054d (diff)
downloadhaskell-20956e5784fe43781d156dd7ab02f0bff4ab41fb.tar.gz
Remove target dependent CPP for Word64/Int64 (#11470)
Primops types were dependent on the target word-size at *compiler* compilation time. It's an issue for multi-target as GHC may not have the correct primops types for the target. This patch fixes some primops types: if they take or return fixed 64-bit values they now always use `Int64#/Word64#`, even on 64-bit architectures (where they used `Int#/Word#` before). Users of these primops may now need to convert from Int64#/Word64# to Int#/Word# (a no-op at runtime). This is a stripped down version of !3658 which goes the all way of changing the underlying primitive types of Word64/Int64. This is left for future work. T12545 allocations increase ~4% on some CI platforms and decrease ~3% on AArch64. Metric Increase: T12545 Metric Decrease: T12545
Diffstat (limited to 'testsuite/tests/primops')
-rw-r--r--testsuite/tests/primops/should_run/T4442.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/testsuite/tests/primops/should_run/T4442.hs b/testsuite/tests/primops/should_run/T4442.hs
index dfdf93cc4f..ad0c882533 100644
--- a/testsuite/tests/primops/should_run/T4442.hs
+++ b/testsuite/tests/primops/should_run/T4442.hs
@@ -222,11 +222,19 @@ main = do
(\arr i s -> case readWord8ArrayAsInt32# arr i s of (# s', a #) -> (# s', I32# a #))
(\arr i (I32# a) s -> writeWord8ArrayAsInt32# arr i a s)
12345678 4
+#if WORD_SIZE_IN_BITS < 64
testInt64Array "Int64#"
(\arr i -> I64# (indexWord8ArrayAsInt64# arr i))
(\arr i s -> case readWord8ArrayAsInt64# arr i s of (# s', a #) -> (# s', I64# a #))
(\arr i (I64# a) s -> writeWord8ArrayAsInt64# arr i a s)
1234567890123 8
+#else
+ testInt64Array "Int64#"
+ (\arr i -> I64# (int64ToInt# (indexWord8ArrayAsInt64# arr i)))
+ (\arr i s -> case readWord8ArrayAsInt64# arr i s of (# s', a #) -> (# s', I64# (int64ToInt# a) #))
+ (\arr i (I64# a) s -> writeWord8ArrayAsInt64# arr i (intToInt64# a) s)
+ 1234567890123 8
+#endif
testIntArray "Int#"
(\arr i -> I# (indexWord8ArrayAsInt# arr i))
(\arr i s -> case readWord8ArrayAsInt# arr i s of (# s', a #) -> (# s', I# a #))
@@ -248,11 +256,19 @@ main = do
(\arr i s -> case readWord8ArrayAsWord32# arr i s of (# s', a #) -> (# s', W32# a #))
(\arr i (W32# a) s -> writeWord8ArrayAsWord32# arr i a s)
12345678 4
+#if WORD_SIZE_IN_BITS < 64
testWord64Array "Word64#"
(\arr i -> W64# (indexWord8ArrayAsWord64# arr i))
(\arr i s -> case readWord8ArrayAsWord64# arr i s of (# s', a #) -> (# s', W64# a #))
(\arr i (W64# a) s -> writeWord8ArrayAsWord64# arr i a s)
1234567890123 8
+#else
+ testWord64Array "Word64#"
+ (\arr i -> W64# (word64ToWord# (indexWord8ArrayAsWord64# arr i)))
+ (\arr i s -> case readWord8ArrayAsWord64# arr i s of (# s', a #) -> (# s', W64# (word64ToWord# a) #))
+ (\arr i (W64# a) s -> writeWord8ArrayAsWord64# arr i (wordToWord64# a) s)
+ 1234567890123 8
+#endif
testWordArray "Word#"
(\arr i -> W# (indexWord8ArrayAsWord# arr i))
(\arr i s -> case readWord8ArrayAsWord# arr i s of (# s', a #) -> (# s', W# a #))