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
=
= CmmCall (infn target) regs es' srt ret
where infn (CmmCallee fn cconv) = CmmCallee fn cconv
infn (CmmPrim p) = CmmPrim p
- es' = [ (inlineExpr u a e, hint) | (e,hint) <- es ]
+ es' = [ (CmmHinted (inlineExpr u a e) hint) | (CmmHinted e hint) <- es ]
inlineStmt u a (CmmCondBranch e d) = CmmCondBranch (inlineExpr u a e) d
inlineStmt u a (CmmSwitch e d) = CmmSwitch (inlineExpr u a e) d
inlineStmt u a (CmmJump e d) = CmmJump (inlineExpr u a e) d
maybe_conversion (MO_U_Conv from _) = Just (from, narrowU)
maybe_conversion (MO_S_Conv from _)
| not (isFloatingRep from) = Just (from, narrowS)
+ -- don't attempt to apply this optimisation when the source
+ -- is a float; see #1916
maybe_conversion _ = Nothing
maybe_comparison (MO_U_Gt _) rep = Just (MO_U_Gt rep)