summaryrefslogtreecommitdiff
path: root/testsuite/tests/codeGen/should_run/cgrun031.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/codeGen/should_run/cgrun031.hs')
-rw-r--r--testsuite/tests/codeGen/should_run/cgrun031.hs45
1 files changed, 45 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/cgrun031.hs b/testsuite/tests/codeGen/should_run/cgrun031.hs
new file mode 100644
index 0000000000..2a2c7a9b64
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/cgrun031.hs
@@ -0,0 +1,45 @@
+{-# LANGUAGE MagicHash #-}
+-- !! test GEN reps w/ unboxed values in them
+-- !! NB: it was the static ones that were hosed...
+--
+module Main ( main ) where
+
+--import PrelBase
+import GHC.Base
+
+main = do
+ putStr (shows (sum ([1..1{-30-}]++[1..1{-40-}]++[11,22])) "\n")
+ putStr (shows (prog 1{-30-} 1{-40-}) "\n")
+
+data Foo a
+ = MkFoo [a] Int# [Int] Int# [(a,Int)] Int#
+ -- The above will cause a *horrible* GEN rep'n.
+
+prog :: Int -> Int -> Int
+
+prog size_1 size_2
+ = let
+ list1 = static1 : (map mk_foo [1 .. size_1])
+ list2 = static2 : (map mk_foo [1 .. size_2])
+ in
+ I# (add_up 0# list1 (reverse list2))
+
+static1 = MkFoo (error "static11") 11# [] 11# (error "static12") 11#
+static2 = MkFoo (error "static21") 22# [] 22# (error "static22") 22#
+
+one, two :: Int
+one = 1; two = 2
+
+mk_foo i@(I# i#)
+ = MkFoo (error "list1") i# [i,i] i# (error "list2") i#
+
+add_up :: Int# -> [Foo a] -> [Foo a] -> Int#
+
+add_up acc [] [] = acc
+add_up acc [] ys = add_up acc ys []
+add_up acc (x:xs) (y:ys) = add_up (acc +# add x y) xs ys
+add_up acc (x:xs) [] = add_up acc xs []
+
+add :: Foo a -> Foo a -> Int#
+add (MkFoo _ _ _ _ _ x) (MkFoo _ _ _ _ _ y)
+ = x +# y