[Git][ghc/ghc][wip/romes/no-simple-joinpoints] uncondInline join points for trivial applications without free vars
Rodrigo Mesquita (@alt-romes)
gitlab at gitlab.haskell.org
Wed Feb 5 11:20:29 UTC 2025
Rodrigo Mesquita pushed to branch wip/romes/no-simple-joinpoints at Glasgow Haskell Compiler / GHC
Commits:
cffdfc86 by Rodrigo Mesquita at 2025-02-05T11:20:14+00:00
uncondInline join points for trivial applications without free vars
- - - - -
1 changed file:
- compiler/GHC/Core/Unfold.hs
Changes:
=====================================
compiler/GHC/Core/Unfold.hs
=====================================
@@ -434,7 +434,7 @@ uncondInline is_join rhs bndrs arity body size
uncondInlineJoin :: [Var] -> CoreExpr -> Bool
-- See Note [Duplicating join points] point (DJ3) in GHC.Core.Opt.Simplify.Iteration
-uncondInlineJoin _bndrs body
+uncondInlineJoin bndrs body
| exprIsTrivial body
= True -- Nullary constructors, literals
@@ -443,9 +443,39 @@ uncondInlineJoin _bndrs body
, isJoinId v -- Indirection to another join point; always inline
= True
+ | trivialAppWithoutFreeArgs
+ -- See Note [...]
+ = True
+
| otherwise
= False
+ where
+ -- Arguments cannot be free Vars!! See Note ...
+ trivialAppWithoutFreeArgs = go body
+ go (App f a)
+
+ -- Go over types
+ | Type _ <- a = go f
+
+ -- 1. If arg is a Var, it must be bound by bndrs
+ | Var v <- a
+ = if v `elem` bndrs {- not free -}
+ then go f
+ else False
+
+ -- 2. If arg is otherwise trivial, continue
+ | exprIsTrivial a = go f
+
+ -- Go over casts (and ticks?)
+ go (Cast e _) = go e
+ go (Tick _ e) = go e
+
+ go (Var _) = True -- reached base case (function being applied, may be free var)
+
+ go e = False -- any other case is not trivial app without free args
+
+
sizeExpr :: UnfoldingOpts
-> Int -- Bomb out if it gets bigger than this
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cffdfc864212e5ae6d91018cc55347565ec3b166
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cffdfc864212e5ae6d91018cc55347565ec3b166
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20250205/5f33d8b2/attachment-0001.html>
More information about the ghc-commits
mailing list