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
Make letremoveunused work for recursive lets again.
[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 a7223e3d8d0433ca55f21a3c5e7a729afb63a4d2..b16eb7ae536f89e475e58851296d98af08e21c4f 100644
(file)
--- a/
cλash/CLasH/Normalize.hs
+++ b/
cλash/CLasH/Normalize.hs
@@
-248,13
+248,17
@@
letremovesimpletop = everywhere ("letremovesimple", inlinebind (\(b, e) -> Trans
-- Unused let binding removal
--------------------------------
letremoveunused, letremoveunusedtop :: Transform
-- Unused let binding removal
--------------------------------
letremoveunused, letremoveunusedtop :: Transform
-letremoveunused expr@(Let _ _) = do
+letremoveunused expr@(Let (NonRec b bound) res) = do
+ let used = expr_uses_binders [b] res
+ if used
+ then return expr
+ else change res
+letremoveunused expr@(Let (Rec binds) res) = do
-- Filter out all unused binds.
let binds' = filter dobind binds
-- Only set the changed flag if binds got removed
-- Filter out all unused binds.
let binds' = filter dobind binds
-- Only set the changed flag if binds got removed
- changeif (length binds' /= length binds) (
mkNonRecLets binds'
res)
+ changeif (length binds' /= length binds) (
Let (Rec binds')
res)
where
where
- (binds, res) = flattenLets expr
bound_exprs = map snd binds
-- For each bind check if the bind is used by res or any of the bound
-- expressions
bound_exprs = map snd binds
-- For each bind check if the bind is used by res or any of the bound
-- expressions