From 40f6fa36c61009396934942a580be62d8cc58da2 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 14 Aug 2009 14:17:51 +0200 Subject: [PATCH] Make letsimpl work on and generate a non-recursive let. Previously, letsimpl would work on a recursive let only, and add a new binding to that recursive let. Now, it works on any let and produces a new non-recursive let. --- "c\316\273ash/CLasH/Normalize.hs" | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git "a/c\316\273ash/CLasH/Normalize.hs" "b/c\316\273ash/CLasH/Normalize.hs" index 6eee47b..dd8244d 100644 --- "a/c\316\273ash/CLasH/Normalize.hs" +++ "b/c\316\273ash/CLasH/Normalize.hs" @@ -148,7 +148,7 @@ letderectop = everywhere ("letderec", letderec) letsimpl, letsimpltop :: Transform -- Put the "in ..." value of a let in its own binding, but not when the -- expression is already a local variable, or not representable (to prevent loops with inlinenonrep). -letsimpl expr@(Let (Rec binds) res) = do +letsimpl expr@(Let binds res) = do repr <- isRepr res local_var <- Trans.lift $ is_local_var res if not local_var && repr @@ -156,8 +156,7 @@ letsimpl expr@(Let (Rec binds) res) = do -- If the result is not a local var already (to prevent loops with -- ourselves), extract it. id <- Trans.lift $ mkBinderFor res "foo" - let bind = (id, res) - change $ Let (Rec (bind:binds)) (Var id) + change $ Let binds (Let (NonRec id res) (Var id)) else -- If the result is already a local var, don't extract it. return expr -- 2.30.2