summaryrefslogtreecommitdiff
path: root/src/Simplify.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Simplify.hs')
-rw-r--r--src/Simplify.hs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/Simplify.hs b/src/Simplify.hs
index cb835aa..e0ab37b 100644
--- a/src/Simplify.hs
+++ b/src/Simplify.hs
@@ -61,14 +61,14 @@ simplify' = \case
-- inlining
ELet _ rhs body
| cheapExpr rhs
- -> acted $ simplify' (subst1 rhs body)
+ -> acted $ simplify' (substInline rhs body)
| Occ lexOcc runOcc <- occCount IZ body
, ((not ?accumInScope || not (hasAdds rhs)) && lexOcc <= One && runOcc <= One) -- without effects, normal rules apply
|| (lexOcc == One && runOcc == One) -- with effects, linear inlining is still allowed, but weakening is not
- -> acted $ simplify' (subst1 rhs body)
+ -> acted $ simplify' (substInline rhs body)
- -- let splitting
+ -- let splitting / let peeling
ELet _ (EPair _ a b) body ->
acted $ simplify' $
ELet ext a $
@@ -76,6 +76,12 @@ simplify' = \case
subst (\_ t -> \case IZ -> EPair ext (EVar ext (typeOf a) (IS IZ)) (EVar ext (typeOf b) IZ)
IS i -> EVar ext t (IS (IS i)))
body
+ ELet _ (EJust _ a) body ->
+ acted $ simplify' $ ELet ext a $ subst0 (EJust ext (EVar ext (typeOf a) IZ)) body
+ ELet _ (EInl _ t2 a) body ->
+ acted $ simplify' $ ELet ext a $ subst0 (EInl ext t2 (EVar ext (typeOf a) IZ)) body
+ ELet _ (EInr _ t1 a) body ->
+ acted $ simplify' $ ELet ext a $ subst0 (EInr ext t1 (EVar ext (typeOf a) IZ)) body
-- let rotation
ELet _ (ELet _ rhs a) b ->