X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Fc%CE%BBash.git;a=blobdiff_plain;f=clash%2FCLasH%2FNormalize.hs;h=11212f943df0678a4b9cef09fb52657ba06bc2dd;hp=a70829ade05370f51d66c9dbe0575e8e124ef97c;hb=ef7d876bddac1ebf8ae72dfac9aff33023650f53;hpb=c86f74b8af5fb3ca467c7a22fa2d14498b46fb1a diff --git a/clash/CLasH/Normalize.hs b/clash/CLasH/Normalize.hs index a70829a..11212f9 100644 --- a/clash/CLasH/Normalize.hs +++ b/clash/CLasH/Normalize.hs @@ -410,15 +410,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) @@ -821,6 +820,10 @@ inlinenonrepresult context expr | not (is_applicable expr) && not (has_free_tyva -- Leave all other expressions unchanged inlinenonrepresult c expr = return expr +---------------------------------------------------------------- +-- Type-class transformations +---------------------------------------------------------------- + -------------------------------- -- ClassOp resolution --------------------------------