Commit 52226dc5 authored by cgibbard's avatar cgibbard Committed by cgibbard

Add a test to check that unboxed sums appear in the core output for a program...

Add a test to check that unboxed sums appear in the core output for a program involving an UNPACK pragma on a sum-typed field.
parent 7d78acab
......@@ -8,3 +8,9 @@ sum_api_annots:
$(CHECK_API_ANNOTATIONS) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" unboxedsums$$number.hs ; \
((number = number + 1)) ; \
done
unpack_sums_7:
$(RM) -f unpack_sums_7.o unpack_sums_7.hi
'$(TEST_HC)' $(TEST_HC_OPTS) -c unpack_sums_7.hs -O -dsuppress-all -ddump-simpl | grep -q '\(#|_#\)'
# This is a test to check for the presence of an unboxed sum in the core for a program using UNPACK
# on a sum type which is evidence that the field has been correctly unpacked.
......@@ -30,6 +30,7 @@ test('unpack_sums_3', omit_ways(['ghci']), compile_and_run, ['-O'])
test('unpack_sums_4', omit_ways(['ghci']), compile_and_run, ['-O'])
test('unpack_sums_5', omit_ways(['ghci']), compile, ['-O'])
test('unpack_sums_6', omit_ways(['ghci']), compile_and_run, ['-O'])
test('unpack_sums_7', [], makefile_test, [])
# TODO: Need to run this in --slow mode only
# test('sum_api_annots',
......@@ -38,4 +39,4 @@ test('unpack_sums_6', omit_ways(['ghci']), compile_and_run, ['-O'])
# makefile_test, [])
test('UbxSumLevPoly', normal, compile, ['-Wno-overlapping-patterns'])
test('T14051', normal, multi_compile, ['T14051.hs', [('T14051a.hs', '')], '-O2 -v0'])
test('T14051', normal, multi_compile, ['T14051.hs', [('T14051a.hs', '')], '-O2 -v0'])
\ No newline at end of file
{-# LANGUAGE BangPatterns #-}
import Data.Time.Clock
import Data.Int
import System.Exit
data A = ANothing | AJust {-# UNPACK #-} !Int
data A = ANothing | AJust {-# UNPACK #-} !Int64
data B = BNothing | BJust {-# UNPACK #-} !A
data C = CNothing | CJust {-# UNPACK #-} !B
data D = DNothing | DJust {-# UNPACK #-} !C
data Unlayered = Unlayered {-# UNPACK #-} !D
data Layered = Layered !(Maybe (Maybe (Maybe (Maybe Int))))
data Layered = Layered !(Maybe (Maybe (Maybe (Maybe Int64))))
makeUnlayered :: Int -> [Unlayered]
makeUnlayered :: Int64 -> [Unlayered]
makeUnlayered n = Unlayered . DJust . CJust . BJust . AJust <$> [1..n]
makeLayered :: Int -> [Layered]
makeLayered :: Int64 -> [Layered]
makeLayered n = Layered . Just . Just . Just . Just <$> [1..n]
sumUnlayered :: [Unlayered] -> Int
sumUnlayered :: [Unlayered] -> Int64
sumUnlayered = go 0
where
go !n [] = n
......@@ -26,7 +27,7 @@ sumUnlayered = go 0
Unlayered (DJust (CJust (BJust (AJust i)))) -> go (n+i) ws
Unlayered _ -> go n ws
sumLayered :: [Layered] -> Int
sumLayered :: [Layered] -> Int64
sumLayered = go 0
where
go !n [] = n
......
module UnpackedSums7 where
data T = MkT {-# UNPACK #-} !MI
data MI = NoI | JI Int
t = MkT (JI 5)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment