Add dead code elimination in cmmMiniInline
[ghc-hetmet.git] / compiler / cmm / CmmOpt.hs
index 320f0a5..b96aa4a 100644 (file)
@@ -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
   = 
@@ -341,7 +346,10 @@ cmmMachOpFold cmp [CmmMachOp conv [x], CmmLit (CmmInt i _)]
   = cmmMachOpFold narrow_cmp [x, CmmLit (CmmInt narrow_i rep)]
  where
     maybe_conversion (MO_U_Conv from _) = Just (from, narrowU)
-    maybe_conversion (MO_S_Conv from _) = Just (from, narrowS)
+    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)