From ce763aa6019c7076e4b8225cc25f27b46371b662 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 26 May 2010 20:05:20 +0200 Subject: [PATCH] Also simplify top level binder scrutinees. Previously, if the scrutinee was a variable reference, it would not be simplified, skipping top level binders as scrutinees. Now only local variable references are skipped. --- "c\316\273ash/CLasH/Normalize.hs" | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git "a/c\316\273ash/CLasH/Normalize.hs" "b/c\316\273ash/CLasH/Normalize.hs" index 4a461f4..e97e425 100644 --- "a/c\316\273ash/CLasH/Normalize.hs" +++ "b/c\316\273ash/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 --- 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 --- 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 - 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) -- 2.30.2