summaryrefslogtreecommitdiff
path: root/testsuite/tests/codeGen/should_run/simd000.hs
diff options
context:
space:
mode:
authorAbhiroop Sarkar <asiamgenius@gmail.com>2018-09-27 15:28:46 -0400
committerBen Gamari <ben@smart-cactus.org>2019-07-01 17:02:29 -0400
commitff823a08f897e770efda4e89c43618dc6e30bb65 (patch)
treef26a80bcb060c8439d2daf8cefc9cb367bb3b388 /testsuite/tests/codeGen/should_run/simd000.hs
parentbd660edeb783a74e5ca3f1f82713b2aeedae19dc (diff)
downloadhaskell-wip/simd.tar.gz
Add support for SIMD operations in the NCGwip/simd
This adds support for constructing vector types from Float#, Double# etc and performing arithmetic operations on them Cleaned-Up-By: Ben Gamari <ben@well-typed.com>
Diffstat (limited to 'testsuite/tests/codeGen/should_run/simd000.hs')
-rw-r--r--testsuite/tests/codeGen/should_run/simd000.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/simd000.hs b/testsuite/tests/codeGen/should_run/simd000.hs
new file mode 100644
index 0000000000..47d69497c0
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/simd000.hs
@@ -0,0 +1,21 @@
+{-# OPTIONS_GHC -mavx #-}
+{-# OPTIONS_GHC -msse4 #-}
+{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE UnboxedTuples #-}
+-- !!! test broadcasting, packing and unpacking for vector types
+
+import GHC.Exts
+
+main :: IO ()
+main = do
+ -- FloatX4#
+ case unpackFloatX4# (broadcastFloatX4# 1.5#) of
+ (# a, b, c, d #) -> print (F# a, F# b, F# c, F# d)
+ case unpackFloatX4# (packFloatX4# (# 4.5#,7.8#, 2.3#, 6.5# #)) of
+ (# a, b, c, d #) -> print (F# a, F# b, F# c, F# d)
+
+ -- DoubleX2#
+ case unpackDoubleX2# (broadcastDoubleX2# 6.5##) of
+ (# a, b #) -> print (D# a, D# b)
+ case unpackDoubleX2# (packDoubleX2# (# 8.9##,7.2## #)) of
+ (# a, b #) -> print (D# a, D# b)