diff options
author | sheaf <sam.derbyshire@gmail.com> | 2022-10-14 14:31:15 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-10-19 10:45:45 -0400 |
commit | 6d7d91817795d7ee7f45557411368a1738daa488 (patch) | |
tree | 41c6e50ae120420658ca8076a469202f7021ffd1 /testsuite | |
parent | 5b3a992f5d166007c3c5a22f120ed08e0a27f01a (diff) | |
download | haskell-6d7d91817795d7ee7f45557411368a1738daa488.tar.gz |
Remove SIMD conversions
This patch makes it so that packing/unpacking SIMD
vectors always uses the right sized types, e.g.
unpacking a Word16X4# will give a tuple of Word16#s.
As a result, we can get rid of the conversion instructions
that were previously required.
Fixes #22296
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/codeGen/should_run/T22296.hs | 41 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/T22296.stdout | 3 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/all.T | 1 |
3 files changed, 45 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/T22296.hs b/testsuite/tests/codeGen/should_run/T22296.hs new file mode 100644 index 0000000000..d5ea23afda --- /dev/null +++ b/testsuite/tests/codeGen/should_run/T22296.hs @@ -0,0 +1,41 @@ +{-# language MagicHash, UnboxedTuples, UnboxedSums #-} + +module Main ( main ) where + +import GHC.Exts +import GHC.Int +import GHC.Word + +foo :: Word16X8# -> Integer +foo w16x8 = + case unpackWord16X8# w16x8 of + (# w1, w2, w3, w4, w5, w6, w7, w8 #) -> + let + s = sum $ map fromIntegral + [ W16# w1, W16# w2, W16# w3, W16# w4 + , W16# w5, W16# w6, W16# w7, W16# w8 ] + in s + +bar :: Int32X4# -> Integer +bar i32x4 = + case unpackInt32X4# i32x4 of + (# i1, i2, i3, i4 #) -> + let + s = sum $ map fromIntegral + [ I32# i1, I32# i2, I32# i3, I32# i4 ] + in s + +baz :: FloatX4# -> Float +baz fx4 = + case unpackFloatX4# fx4 of + (# f1, f2, f3, f4 #) -> + let + s = sum + [ F# f1, F# f2, F# f3, F# f4 ] + in s + +main :: IO () +main = do + print ( foo ( broadcastWord16X8# ( wordToWord16# 1## ) ) ) + print ( bar ( broadcastInt32X4# ( intToInt32# 1# ) ) ) + print ( baz ( broadcastFloatX4# ( 1.0# ) ) ) diff --git a/testsuite/tests/codeGen/should_run/T22296.stdout b/testsuite/tests/codeGen/should_run/T22296.stdout new file mode 100644 index 0000000000..52b2242af3 --- /dev/null +++ b/testsuite/tests/codeGen/should_run/T22296.stdout @@ -0,0 +1,3 @@ +8 +4 +4.0 diff --git a/testsuite/tests/codeGen/should_run/all.T b/testsuite/tests/codeGen/should_run/all.T index 85acd521f6..e8f20b5837 100644 --- a/testsuite/tests/codeGen/should_run/all.T +++ b/testsuite/tests/codeGen/should_run/all.T @@ -218,3 +218,4 @@ test('T21141', normal, compile_and_run, ['']) test('T21186', normal, compile_and_run, ['']) test('T20640a', normal, compile_and_run, ['']) test('T20640b', normal, compile_and_run, ['']) +test('T22296',[only_ways(llvm_ways)],compile_and_run,['']) |