From: Matthijs Kooijman Date: Fri, 14 Aug 2009 14:08:08 +0000 (+0200) Subject: Make letremoveunused work for non-recursive lets. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=26ad8ba14c7c63978fc51fc81b92888e8e3963ef;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Make letremoveunused work for non-recursive lets. --- diff --git "a/c\316\273ash/CLasH/Normalize.hs" "b/c\316\273ash/CLasH/Normalize.hs" index bade853..984d739 100644 --- "a/c\316\273ash/CLasH/Normalize.hs" +++ "b/c\316\273ash/CLasH/Normalize.hs" @@ -204,12 +204,13 @@ letremovesimpletop = everywhere ("letremovesimple", inlinebind (\(b, e) -> Trans -- Unused let binding removal -------------------------------- letremoveunused, letremoveunusedtop :: Transform -letremoveunused expr@(Let (Rec binds) res) = do +letremoveunused expr@(Let _ _) = do -- Filter out all unused binds. let binds' = filter dobind binds -- Only set the changed flag if binds got removed - changeif (length binds' /= length binds) (Let (Rec binds') res) + changeif (length binds' /= length binds) (mkNonRecLets binds' res) 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