[commit: ghc] master: Make assignTemp_ less pessimistic (18691d4)
Johan Tibell
johan.tibell at gmail.com
Mon May 30 22:30:01 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/ghc
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/18691d440f90a3dff4ef538091c886af505e5cf5
>---------------------------------------------------------------
commit 18691d440f90a3dff4ef538091c886af505e5cf5
Author: Johan Tibell <johan.tibell at gmail.com>
Date: Thu May 19 17:34:20 2011 +0200
Make assignTemp_ less pessimistic
assignTemp_ is intended to make sure that the expression gets assigned
to a temporary in case that's needed in order to avoid a register
getting trashed due to a function call.
>---------------------------------------------------------------
compiler/codeGen/CgUtils.hs | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
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) }
More information about the Cvs-ghc
mailing list