diff options
Diffstat (limited to 'testsuite/tests/cpranal')
-rw-r--r-- | testsuite/tests/cpranal/sigs/CaseBinderCPR.hs | 21 | ||||
-rw-r--r-- | testsuite/tests/cpranal/sigs/CaseBinderCPR.stderr | 7 | ||||
-rw-r--r-- | testsuite/tests/cpranal/sigs/Makefile | 3 | ||||
-rw-r--r-- | testsuite/tests/cpranal/sigs/T19232.hs | 14 | ||||
-rw-r--r-- | testsuite/tests/cpranal/sigs/T19232.stderr | 6 | ||||
-rw-r--r-- | testsuite/tests/cpranal/sigs/all.T | 9 |
6 files changed, 60 insertions, 0 deletions
diff --git a/testsuite/tests/cpranal/sigs/CaseBinderCPR.hs b/testsuite/tests/cpranal/sigs/CaseBinderCPR.hs new file mode 100644 index 0000000000..1310031f42 --- /dev/null +++ b/testsuite/tests/cpranal/sigs/CaseBinderCPR.hs @@ -0,0 +1,21 @@ +module CaseBinderCPR where + +-- This example, taken from nofib's transform (and heavily reduced) ensures that +-- CPR information is added to a case binder + +f_list_cmp::(t1 -> t1 -> Int) -> [t1] -> [t1] -> Int; +f_list_cmp a_cmp [] []= 0 +f_list_cmp a_cmp [] a_ys= -1 +f_list_cmp a_cmp a_xs []= 1 +f_list_cmp a_cmp (a_x:a_xs) (a_y:a_ys)= + if r_order == 0 + then f_list_cmp a_cmp a_xs a_ys + else r_order + where + r_order = a_cmp a_x a_y + + +-- But not every case binder has the CPR property. +-- x below does not and we should not CPR nestedly for it: +g :: [Int] -> (Int, Int) +g xs = let x = xs !! 0 in x `seq` (x, x) diff --git a/testsuite/tests/cpranal/sigs/CaseBinderCPR.stderr b/testsuite/tests/cpranal/sigs/CaseBinderCPR.stderr new file mode 100644 index 0000000000..7f98fe0612 --- /dev/null +++ b/testsuite/tests/cpranal/sigs/CaseBinderCPR.stderr @@ -0,0 +1,7 @@ + +==================== Cpr signatures ==================== +CaseBinderCPR.$trModule: +CaseBinderCPR.f_list_cmp: +CaseBinderCPR.g: m1 + + diff --git a/testsuite/tests/cpranal/sigs/Makefile b/testsuite/tests/cpranal/sigs/Makefile new file mode 100644 index 0000000000..9101fbd40a --- /dev/null +++ b/testsuite/tests/cpranal/sigs/Makefile @@ -0,0 +1,3 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk diff --git a/testsuite/tests/cpranal/sigs/T19232.hs b/testsuite/tests/cpranal/sigs/T19232.hs new file mode 100644 index 0000000000..3ea087d585 --- /dev/null +++ b/testsuite/tests/cpranal/sigs/T19232.hs @@ -0,0 +1,14 @@ +module T19232 where + +-- | `x` is not used strictly and hence will not be available unboxed, so +-- the `otherwise` RHS does not have the CPR property, even if it returns +-- a case binder. +f :: Bool -> Int -> Int +f True x + | x == 3 = 8 + | otherwise = x -- NB: the condition was flipped so that we can't substitute `x` for a constant here +f False _ = 3 +{-# NOINLINE f #-} + +-- See also test CaseBinderCPR + diff --git a/testsuite/tests/cpranal/sigs/T19232.stderr b/testsuite/tests/cpranal/sigs/T19232.stderr new file mode 100644 index 0000000000..3aa701833b --- /dev/null +++ b/testsuite/tests/cpranal/sigs/T19232.stderr @@ -0,0 +1,6 @@ + +==================== Cpr signatures ==================== +T19232.$trModule: +T19232.f: + + diff --git a/testsuite/tests/cpranal/sigs/all.T b/testsuite/tests/cpranal/sigs/all.T new file mode 100644 index 0000000000..f5ac233a8c --- /dev/null +++ b/testsuite/tests/cpranal/sigs/all.T @@ -0,0 +1,9 @@ +# We are testing the result of an optimization, so no use +# running them in various runtimes +setTestOpts(only_ways(['optasm'])) +# This directory contains tests where we annotate functions with expected +# CPR signatures, and verify that these are actually those found by the compiler +setTestOpts(extra_hc_opts('-ddump-cpr-signatures')) + +test('CaseBinderCPR', normal, compile, ['']) +test('T19232', normal, compile, ['']) |