From ae72991e2f0343c075a30c0a5a7d4ac18e9ef500 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Thu, 20 Dec 2007 15:17:34 +0000 Subject: [PATCH] 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. --- compiler/cmm/CmmOpt.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/cmm/CmmOpt.hs b/compiler/cmm/CmmOpt.hs index 379d7a2..b96aa4a 100644 --- a/compiler/cmm/CmmOpt.hs +++ b/compiler/cmm/CmmOpt.hs @@ -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 = -- 1.7.10.4