X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=c%CE%BBash%2FCLasH%2FNormalize.hs;h=1f5ee427069751c0d7d56d4ecb563c5fad978c8e;hb=7d3ab3315462e18a84e6d0312dd3c444292e43bb;hp=2f74be883ffa601522ae8d4350b40332b2c3896e;hpb=332de8b1e2d6bf8f033e09a30adaeecd1e023575;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git "a/c\316\273ash/CLasH/Normalize.hs" "b/c\316\273ash/CLasH/Normalize.hs" index 2f74be8..1f5ee42 100644 --- "a/c\316\273ash/CLasH/Normalize.hs" +++ "b/c\316\273ash/CLasH/Normalize.hs" @@ -324,10 +324,11 @@ inlinetoplevel, inlinetopleveltop :: Transform -- Any system name is candidate for inlining. Never inline user-defined -- functions, to preserver structure. inlinetoplevel expr@(Var f) | not $ isUserDefined f = do + norm <- isNormalizeable f -- See if this is a top level binding for which we have a body body_maybe <- Trans.lift $ getGlobalBind f - case body_maybe of - Just body -> do + if norm && Maybe.isJust body_maybe + then do -- Get the normalized version norm <- Trans.lift $ getNormalized f if needsInline norm @@ -335,9 +336,9 @@ inlinetoplevel expr@(Var f) | not $ isUserDefined f = do change norm else return expr - -- No body, this is probably a local variable or builtin or external - -- function. - Nothing -> return expr + else + -- No body or not normalizeable. + return expr -- Leave all other expressions unchanged inlinetoplevel expr = return expr inlinetopleveltop = everywhere ("inlinetoplevel", inlinetoplevel) @@ -427,7 +428,7 @@ casesimpl expr@(Case scrut b ty alts) = do -- binding containing a case expression. dobndr :: CoreBndr -> Int -> TransformMonad (CoreBndr, Maybe (CoreBndr, CoreExpr)) dobndr b i = do - repr <- isRepr (Var b) + repr <- isRepr b -- Is b wild (e.g., not a free var of expr. Since b is only in scope -- in expr, this means that b is unused if expr does not use it.) let wild = not (VarSet.elemVarSet b free_vars)