From 51e3bb6db85c20cb6b287fa5ec7cfe679a7e5259 Mon Sep 17 00:00:00 2001 From: Andreas Klebinger Date: Fri, 27 Nov 2020 14:24:11 +0100 Subject: CodeGen: Make folds User/DefinerOfRegs INLINEABLE. Reduces allocation for the test case I was looking at by about 1.2%. Mostly from avoiding allocation of some folding functions which turn into let-no-escape bindings which just reuse their environment instead. We also force inlining in a few key places in CmmSink which helps a bit more. --- compiler/GHC/Cmm/Node.hs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'compiler/GHC/Cmm/Node.hs') diff --git a/compiler/GHC/Cmm/Node.hs b/compiler/GHC/Cmm/Node.hs index 61b4030620..943efaa3fd 100644 --- a/compiler/GHC/Cmm/Node.hs +++ b/compiler/GHC/Cmm/Node.hs @@ -318,6 +318,7 @@ foreignTargetHints target -- Instances of register and slot users / definers instance UserOfRegs LocalReg (CmmNode e x) where + {-# INLINEABLE foldRegsUsed #-} foldRegsUsed platform f !z n = case n of CmmAssign _ expr -> fold f z expr CmmStore addr rval -> fold f (fold f z addr) rval @@ -332,6 +333,7 @@ instance UserOfRegs LocalReg (CmmNode e x) where fold f z n = foldRegsUsed platform f z n instance UserOfRegs GlobalReg (CmmNode e x) where + {-# INLINEABLE foldRegsUsed #-} foldRegsUsed platform f !z n = case n of CmmAssign _ expr -> fold f z expr CmmStore addr rval -> fold f (fold f z addr) rval @@ -348,10 +350,12 @@ instance UserOfRegs GlobalReg (CmmNode e x) where instance (Ord r, UserOfRegs r CmmReg) => UserOfRegs r ForeignTarget where -- The (Ord r) in the context is necessary here -- See Note [Recursive superclasses] in GHC.Tc.TyCl.Instance + {-# INLINEABLE foldRegsUsed #-} foldRegsUsed _ _ !z (PrimTarget _) = z foldRegsUsed platform f !z (ForeignTarget e _) = foldRegsUsed platform f z e instance DefinerOfRegs LocalReg (CmmNode e x) where + {-# INLINEABLE foldRegsDefd #-} foldRegsDefd platform f !z n = case n of CmmAssign lhs _ -> fold f z lhs CmmUnsafeForeignCall _ fs _ -> fold f z fs @@ -362,6 +366,7 @@ instance DefinerOfRegs LocalReg (CmmNode e x) where fold f z n = foldRegsDefd platform f z n instance DefinerOfRegs GlobalReg (CmmNode e x) where + {-# INLINEABLE foldRegsDefd #-} foldRegsDefd platform f !z n = case n of CmmAssign lhs _ -> fold f z lhs CmmUnsafeForeignCall tgt _ _ -> fold f z (foreignTargetRegs tgt) -- cgit v1.2.1