[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:15:20 UTC 2025
Rodrigo Mesquita pushed to branch wip/romes/no-simple-joinpoints at Glasgow Haskell Compiler / GHC
Commits:
980225e3 by Rodrigo Mesquita at 2025-02-05T11:14:20+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,38 @@ 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
+ , v `elem` bndrs {- not free -}
+ = go f
+
+ -- 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/980225e3dae2f5949ce53fb915b2bd88570309c3
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/980225e3dae2f5949ce53fb915b2bd88570309c3
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/a2897ed3/attachment-0001.html>
More information about the ghc-commits
mailing list