mirror of
https://github.com/grin-compiler/grin.git
synced 2024-09-11 07:25:28 +03:00
test if interproedural DVE bug does not apply to simple DVE
This commit is contained in:
parent
ba9d579e26
commit
fca2d680b7
@ -258,3 +258,46 @@ spec = do
|
||||
effMap = effectMap (tyEnv, before)
|
||||
dveExp = simpleDeadVariableElimination tyEnv effMap before
|
||||
dveExp `sameAs` after
|
||||
|
||||
describe "interprocedural DVE regression tests" $ do
|
||||
it "Not explicitly covered alternatives trigger undefined replacements" $ do
|
||||
let before = [prog|
|
||||
grinMain =
|
||||
v0 <- _prim_int_add 1 1
|
||||
v1 <- case v0 of
|
||||
2 ->
|
||||
v2 <- _prim_int_lt 1 3
|
||||
v3 <- case v2 of
|
||||
#False -> pure v0
|
||||
#True -> pure 1
|
||||
case v3 of
|
||||
0 -> pure (CGT)
|
||||
1 -> pure (CLT)
|
||||
1 -> pure (CEQ)
|
||||
-- If #default is changed to explicit alternatives the undefineds are not introduced.
|
||||
-- Undefineds are introduced for missing alternatives too.
|
||||
case v1 of
|
||||
(CEQ) -> _prim_int_print 1
|
||||
#default -> _prim_int_print 2
|
||||
|]
|
||||
let after = [prog|
|
||||
grinMain =
|
||||
v0 <- _prim_int_add 1 1
|
||||
v1 <- case v0 of
|
||||
2 ->
|
||||
v2 <- _prim_int_lt 1 3
|
||||
v3 <- case v2 of
|
||||
#False -> pure v0
|
||||
#True -> pure 1
|
||||
case v3 of
|
||||
0 -> pure (CGT)
|
||||
1 -> pure (CLT)
|
||||
1 -> pure (CEQ)
|
||||
case v1 of
|
||||
(CEQ) -> _prim_int_print 1
|
||||
#default -> _prim_int_print 2
|
||||
|]
|
||||
let tyEnv = inferTypeEnv before
|
||||
effMap = effectMap (tyEnv, before)
|
||||
dveExp = simpleDeadVariableElimination tyEnv effMap before
|
||||
dveExp `sameAs` after
|
||||
|
Loading…
Reference in New Issue
Block a user