[commit: ghc] wip/T16039: implement exprIsTrivial too (78b52d3)

git at git.haskell.org git at git.haskell.org
Sun Mar 31 15:07:35 UTC 2019


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/T16039
Link       : http://ghc.haskell.org/trac/ghc/changeset/78b52d3e09eba68257e3e3711ef6c0fa8c96e16b/ghc

>---------------------------------------------------------------

commit 78b52d3e09eba68257e3e3711ef6c0fa8c96e16b
Author: Gabor Greif <ggreif at gmail.com>
Date:   Wed Dec 19 16:49:20 2018 +0100

    implement exprIsTrivial too


>---------------------------------------------------------------

78b52d3e09eba68257e3e3711ef6c0fa8c96e16b
 compiler/coreSyn/CoreUtils.hs | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/compiler/coreSyn/CoreUtils.hs b/compiler/coreSyn/CoreUtils.hs
index ea76f6d..ea3fe01 100644
--- a/compiler/coreSyn/CoreUtils.hs
+++ b/compiler/coreSyn/CoreUtils.hs
@@ -960,7 +960,11 @@ exprIsTrivial (Var _)          = True        -- See Note [Variables are trivial]
 exprIsTrivial (Type _)         = True
 exprIsTrivial (Coercion _)     = True
 exprIsTrivial (Lit lit)        = litIsTrivial lit
-exprIsTrivial (App e arg)      = not (isRuntimeArg arg) && exprIsTrivial e
+exprIsTrivial (App e arg)
+ | App (Var f) Type {} <- e
+ , f `hasKey` noinlineIdKey    = pprTrace "exprIsTrivial" (ppr arg) exprIsTrivial arg
+ | not (isRuntimeArg arg)      = exprIsTrivial e
+ | otherwise                   = False
 exprIsTrivial (Lam b e)        = not (isRuntimeVar b) && exprIsTrivial e
 exprIsTrivial (Tick t e)       = not (tickishIsCode t) && exprIsTrivial e
                                  -- See Note [Tick trivial]
@@ -1240,7 +1244,7 @@ exprIsCheapX ok_app e
                     | otherwise       = go n e
     go n (App f e)  | App (Var v) Type {} <- f
                     , v `hasKey` noinlineIdKey
-                    , isRuntimeArg e  = go n e
+                    , isRuntimeArg e  = pprTrace "exprIsCheapX" (ppr e) go n e
     go n (App f e)  | isRuntimeArg e  = go (n+1) f && ok e
                     | otherwise       = go n f
     go n (Let (NonRec _ r) e)         = go n e && ok r



More information about the ghc-commits mailing list