X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=c%CE%BBash%2FCLasH%2FNormalize.hs;h=ec7a66bf991ea5f5ff65fc5b3ac231ec7123ab82;hb=c3fd4c4ef1372598fa715b6e9fc48f1eda57d4ce;hp=7d28473e0d2b10bd09ca435ee6788faf8c8b0dee;hpb=dda227b02df4fc23e7fd658dd9e5a7ee93f494bc;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 7d28473..ec7a66b 100644 --- "a/c\316\273ash/CLasH/Normalize.hs" +++ "b/c\316\273ash/CLasH/Normalize.hs" @@ -323,7 +323,7 @@ inlinenonreptop = everywhere ("inlinenonrep", inlinebind ((Monad.liftM not) . is inlinetoplevel, inlinetopleveltop :: Transform -- Any system name is candidate for inlining. Never inline user-defined -- functions, to preserver structure. -inlinetoplevel expr@(Var f) | (Name.isSystemName . Id.idName) f = do +inlinetoplevel expr@(Var f) | not $ isUserDefined f = do -- See if this is a top level binding for which we have a body body_maybe <- Trans.lift $ getGlobalBind f case body_maybe of @@ -343,9 +343,13 @@ inlinetoplevel expr = return expr inlinetopleveltop = everywhere ("inlinetoplevel", inlinetoplevel) needsInline :: CoreExpr -> Bool --- Any function that just evaluates to another function, can be inlined ---needsInline (Var f) = True -needsInline _ = False +needsInline expr = case splitNormalized expr of + -- Inline any function that only has a single definition, it is probably + -- simple enough. This might inline some stuff that it shouldn't though it + -- will never inline user-defined functions (inlinetoplevel only tries + -- system names) and inlining should never break things. + (args, [bind], res) -> True + _ -> False -------------------------------- -- Scrutinee simplification