summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2022-07-12 16:07:12 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-07-18 16:38:04 -0400
commit9bdfdd98e9be4eb0ff687e638fe5c33c6284a31c (patch)
treed44d344e990f7024cc6ffac1fda7c3065d341cab
parentae3b3b62b422fc88a06ed06384caf27be91b1d37 (diff)
downloadhaskell-9bdfdd98e9be4eb0ff687e638fe5c33c6284a31c.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