Commit ae72991e authored by Simon Marlow's avatar Simon Marlow
Browse files

Add dead code elimination in cmmMiniInline

cmmMiniInline counts the uses of local variables, so it can easily
eliminate assigments to unused locals.  This almost never gets
triggered, as we don't generate any dead assignments, but it will be
needed by a forthcoming cleanup in CgUtils.emitSwitch.
parent 55030d7a
......@@ -102,6 +102,11 @@ cmmMiniInline blocks = map do_inline blocks
cmmMiniInlineStmts :: UniqFM Int -> [CmmStmt] -> [CmmStmt]
cmmMiniInlineStmts uses [] = []
cmmMiniInlineStmts uses (stmt@(CmmAssign (CmmLocal (LocalReg u _ _)) expr) : stmts)
-- not used at all: just discard this assignment
| Nothing <- lookupUFM uses u
= cmmMiniInlineStmts uses stmts
-- used once: try to inline at the use site
| Just 1 <- lookupUFM uses u,
Just stmts' <- lookForInline u expr stmts
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment