summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorAustin Seipp <austin@well-typed.com>2013-10-01 21:20:24 -0500
committerAustin Seipp <austin@well-typed.com>2013-10-01 21:20:53 -0500
commite6632902f5e1ab2094b1df98aee27418c5a657ba (patch)
tree76add96114f975fc45e21dba2e925d4145e95dfd /testsuite
parent40177b28d203fa621d25e1e344355dffa6009bad (diff)
downloadhaskell-e6632902f5e1ab2094b1df98aee27418c5a657ba.tar.gz
Add tests for prefetch primops (#8256)
Authored-by: Carter Tazio Schonwald <carter.schonwald@gmail.com> Signed-off-by: Austin Seipp <austin@well-typed.com>
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/codeGen/should_run/T8256.hs48
-rw-r--r--testsuite/tests/codeGen/should_run/T8256.stdout1
-rw-r--r--testsuite/tests/codeGen/should_run/all.T1
3 files changed, 50 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/T8256.hs b/testsuite/tests/codeGen/should_run/T8256.hs
new file mode 100644
index 0000000000..7f8314c8df
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T8256.hs
@@ -0,0 +1,48 @@
+{-# LANGUAGE MagicHash, UnboxedTuples #-}
+
+
+
+import GHC.Prim
+
+import Data.Vector.Storable.Mutable
+import Foreign.Ptr
+import GHC.ST
+import Data.Primitive.ByteArray
+import Control.Monad.Primitive
+
+
+
+sameByteArray :: Control.Monad.Primitive.PrimMonad m => ByteArray -> ByteArray -> m Bool
+sameByteArray ar1 ar2 =
+ do v1 <- unsafeThawByteArray ar1
+ v2 <- unsafeThawByteArray ar2
+ return $ sameMutableByteArray v1 v2
+
+pf0 (ByteArray by) = ByteArray ( prefetchByteArray0# by 1#)
+
+pf1 (ByteArray by) = ByteArray (prefetchByteArray1# by 1#)
+
+pf2 (ByteArray by) = ByteArray ( prefetchByteArray2# by 1#)
+
+pf3 (ByteArray by) = ByteArray ( prefetchByteArray3# by 1#)
+
+
+monoSame v f = sameByteArray v (f v)
+
+
+
+
+main :: IO ()
+main = do
+ mv1 <- newByteArray 17
+ v1 <- unsafeFreezeByteArray mv1
+ return ()
+ t0<- monoSame v1 pf0
+ t1 <- monoSame v1 pf1
+ t2 <- monoSame v1 pf2
+ t3 <- monoSame v1 pf3
+ if t0 && t1 && t2 && t3 then putStrLn "success" else error "bad prefetch operation! please report"
+
+
+
+
diff --git a/testsuite/tests/codeGen/should_run/T8256.stdout b/testsuite/tests/codeGen/should_run/T8256.stdout
new file mode 100644
index 0000000000..2e9ba477f8
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T8256.stdout
@@ -0,0 +1 @@
+success
diff --git a/testsuite/tests/codeGen/should_run/all.T b/testsuite/tests/codeGen/should_run/all.T
index 46cddbb0b9..f7b36ff433 100644
--- a/testsuite/tests/codeGen/should_run/all.T
+++ b/testsuite/tests/codeGen/should_run/all.T
@@ -114,3 +114,4 @@ test('T7361', normal, compile_and_run, [''])
test('T7600', normal, compile_and_run, [''])
test('T8103', only_ways(['normal']), compile_and_run, [''])
test('T7953', reqlib('random'), compile_and_run, [''])
+test('T8256',normal, compile_and_run, [''])