projects
/
matthijs
/
master-project
/
cλash.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Also simplify top level binder scrutinees.
[matthijs/master-project/cλash.git]
/
cλash
/
CLasH
/
Normalize.hs
diff --git
a/cλash/CLasH/Normalize.hs
b/cλash/CLasH/Normalize.hs
index 4a461f4e7b80973b27f56ad793bdf30ee97c1cf3..e97e425c6e023bfc8ea9939c4f32f5bbc092a58e 100644
(file)
--- a/
cλash/CLasH/Normalize.hs
+++ b/
cλash/CLasH/Normalize.hs
@@
-406,15
+406,14
@@
funextract c expr = return expr
-- Make sure the scrutinee of a case expression is a local variable
-- reference.
scrutsimpl :: Transform
-- Make sure the scrutinee of a case expression is a local variable
-- reference.
scrutsimpl :: Transform
--- Don't touch scrutinees that are already simple
-scrutsimpl c expr@(Case (Var _) _ _ _) = return expr
--- Replace all other cases with a let that binds the scrutinee and a new
+-- Replace a case expression with a let that binds the scrutinee and a new
-- simple scrutinee, but only when the scrutinee is representable (to prevent
-- loops with inlinenonrep, though I don't think a non-representable scrutinee
-- simple scrutinee, but only when the scrutinee is representable (to prevent
-- loops with inlinenonrep, though I don't think a non-representable scrutinee
--- will be supported anyway...)
+-- will be supported anyway...)
and is not a local variable already.
scrutsimpl c expr@(Case scrut b ty alts) = do
repr <- isRepr scrut
scrutsimpl c expr@(Case scrut b ty alts) = do
repr <- isRepr scrut
- if repr
+ local_var <- Trans.lift $ is_local_var scrut
+ if repr && not local_var
then do
id <- Trans.lift $ mkBinderFor scrut "scrut"
change $ Let (NonRec id scrut) (Case (Var id) b ty alts)
then do
id <- Trans.lift $ mkBinderFor scrut "scrut"
change $ Let (NonRec id scrut) (Case (Var id) b ty alts)