summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2022-07-12 16:07:12 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2022-07-18 09:01:28 +0100
commitd49abf3d436aebb95487e6661ebb821fcbf807e4 (patch)
treee6988974ae9e79044f4a35aebb777d00589cbed6
parent6860f99eacbee57ece9173b0b8bc27321aa756ef (diff)
downloadhaskell-d49abf3d436aebb95487e6661ebb821fcbf807e4.tar.gz
Inline mapAccumLM
This function is called in inner loops in the compiler, and it's overloaded and higher order. Best just to inline it. This popped up when I was looking at something else. I think perhaps GHC is delicately balanced on the cusp of inlining this automatically.
-rw-r--r--compiler/GHC/Utils/Monad.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/GHC/Utils/Monad.hs b/compiler/GHC/Utils/Monad.hs
index 1a4ddae504..3bf8737990 100644
--- a/compiler/GHC/Utils/Monad.hs
+++ b/compiler/GHC/Utils/Monad.hs
@@ -147,6 +147,11 @@ mapAccumLM :: Monad m
-> acc -- ^ initial state
-> [x] -- ^ inputs
-> m (acc, [y]) -- ^ final state, outputs
+{-# INLINE mapAccumLM #-}
+-- INLINE pragma. mapAccumLM is called in inner loops. Like 'map',
+-- we inline it so that we can take advantage of knowing 'f'.
+-- This makes a few percent difference (in compiler allocations)
+-- when compiling perf/compiler/T9675
mapAccumLM f s xs =
go s xs
where