X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2FcodeGen%2FCgUtils.hs;fp=compiler%2FcodeGen%2FCgUtils.hs;h=63d99a629fa4c4bec6984d56e006dd96d179e2f0;hp=4df7c77914e62f237077a30803e021bffddff014;hb=18691d440f90a3dff4ef538091c886af505e5cf5;hpb=622c3cfe2b3ebde891981544c0eea525eaa55e6f diff --git a/compiler/codeGen/CgUtils.hs b/compiler/codeGen/CgUtils.hs index 4df7c77..63d99a6 100644 --- a/compiler/codeGen/CgUtils.hs +++ b/compiler/codeGen/CgUtils.hs @@ -601,13 +601,17 @@ assignTemp e ; stmtC (CmmAssign (CmmLocal reg) e) ; return (CmmReg (CmmLocal reg)) } --- | Assign the expression to a temporary register and return an --- expression referring to this register. +-- | If the expression is trivial and doesn't refer to a global +-- register, return it. Otherwise, assign the expression to a +-- temporary register and return an expression referring to this +-- register. assignTemp_ :: CmmExpr -> FCode CmmExpr -assignTemp_ e = do - reg <- newTemp (cmmExprType e) - stmtC (CmmAssign (CmmLocal reg) e) - return (CmmReg (CmmLocal reg)) +assignTemp_ e + | isTrivialCmmExpr e && hasNoGlobalRegs e = return e + | otherwise = do + reg <- newTemp (cmmExprType e) + stmtC (CmmAssign (CmmLocal reg) e) + return (CmmReg (CmmLocal reg)) newTemp :: CmmType -> FCode LocalReg newTemp rep = do { uniq <- newUnique; return (LocalReg uniq rep) }