diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2020-03-09 10:28:30 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-03-14 05:29:55 -0400 |
commit | 2f8c77673f1faf0d8fed6df2bdd1ca15d696a010 (patch) | |
tree | 03fe4a9e8f6f66ce971cebbc01282a7871657476 | |
parent | fdfa2d0121ca8cc22479dd17a74afa58fc2b39f5 (diff) | |
download | haskell-2f8c77673f1faf0d8fed6df2bdd1ca15d696a010.tar.gz |
Simple refactor of cheapEqExpr
No change in functionality. Just seems tidier (and signficantly more
efficient) to deal with ticks directly than to call stripTicksTopE.
-rw-r--r-- | compiler/GHC/Core/Utils.hs | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/compiler/GHC/Core/Utils.hs b/compiler/GHC/Core/Utils.hs index 07faeee243..c846d2ac2e 100644 --- a/compiler/GHC/Core/Utils.hs +++ b/compiler/GHC/Core/Utils.hs @@ -2065,25 +2065,23 @@ cheapEqExpr = cheapEqExpr' (const False) -- | Cheap expression equality test, can ignore ticks by type. cheapEqExpr' :: (Tickish Id -> Bool) -> Expr b -> Expr b -> Bool -cheapEqExpr' ignoreTick = go_s - where go_s = go `on` stripTicksTopE ignoreTick - go (Var v1) (Var v2) = v1 == v2 - go (Lit lit1) (Lit lit2) = lit1 == lit2 - go (Type t1) (Type t2) = t1 `eqType` t2 - go (Coercion c1) (Coercion c2) = c1 `eqCoercion` c2 - - go (App f1 a1) (App f2 a2) - = f1 `go_s` f2 && a1 `go_s` a2 +{-# INLINE cheapEqExpr' #-} +cheapEqExpr' ignoreTick e1 e2 + = go e1 e2 + where + go (Var v1) (Var v2) = v1 == v2 + go (Lit lit1) (Lit lit2) = lit1 == lit2 + go (Type t1) (Type t2) = t1 `eqType` t2 + go (Coercion c1) (Coercion c2) = c1 `eqCoercion` c2 + go (App f1 a1) (App f2 a2) = f1 `go` f2 && a1 `go` a2 + go (Cast e1 t1) (Cast e2 t2) = e1 `go` e2 && t1 `eqCoercion` t2 - go (Cast e1 t1) (Cast e2 t2) - = e1 `go_s` e2 && t1 `eqCoercion` t2 + go (Tick t1 e1) e2 | ignoreTick t1 = go e1 e2 + go e1 (Tick t2 e2) | ignoreTick t2 = go e1 e2 + go (Tick t1 e1) (Tick t2 e2) = t1 == t2 && e1 `go` e2 - go (Tick t1 e1) (Tick t2 e2) - = t1 == t2 && e1 `go_s` e2 + go _ _ = False - go _ _ = False - {-# INLINE go #-} -{-# INLINE cheapEqExpr' #-} exprIsBig :: Expr b -> Bool -- ^ Returns @True@ of expressions that are too big to be compared by 'cheapEqExpr' |