blob: fd922595ae4b026ec0b40b7001b79967499e3a54 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
module T14152 where
{-
This test case tests exitification. With exitification, the "case thunk" should
be lifted out of "innerGo", then "thunk" gets inlined, we have case-of-case and
case-of-known-constructor and the string "dead code" should disappear
The test case T14152b uses the same file, but with -fno-exitification, and checks
that the strings "dead code" is still present. If not, then some other optimization
does the job now (great!), but then we need to come up with a better test case
for exitification (or get rid of it).
-}
go 0 y = y
go n y = innerGo n y
where
innerGo 10 y = 0 -- we want to be lazy in thunk
innerGo 0 y = case thunk of
Nothing -> error "dead code"
Just y' -> go (n-1) (y + y')
innerGo n y = innerGo (n-1) (y*y)
thunk = if y==0 then Just (y + y) else Just y
|