[Git][ghc/ghc][wip/T21694a] Improve exprIsDeadEnd

Simon Peyton Jones (@simonpj) gitlab at gitlab.haskell.org
Fri Aug 19 15:31:22 UTC 2022



Simon Peyton Jones pushed to branch wip/T21694a at Glasgow Haskell Compiler / GHC


Commits:
d22bec7c by Simon Peyton Jones at 2022-08-19T16:32:44+01:00
Improve exprIsDeadEnd

- - - - -


1 changed file:

- compiler/GHC/Core/Utils.hs


Changes:

=====================================
compiler/GHC/Core/Utils.hs
=====================================
@@ -1083,21 +1083,25 @@ expensive.
 exprIsDeadEnd :: CoreExpr -> Bool
 -- See Note [Bottoming expressions]
 exprIsDeadEnd e
-  | isEmptyTy (exprType e)
-  = True
-  | otherwise
   = go 0 e
   where
-    go n (Var v)                 = isDeadEndAppSig (idDmdSig v) n
+    go _ (Lit {})                = False
+    go _ (Type {})               = False
+    go _ (Coercion {})           = False
     go n (App e a) | isTypeArg a = go n e
                    | otherwise   = go (n+1) e
     go n (Tick _ e)              = go n e
     go n (Cast e _)              = go n e
     go n (Let _ e)               = go n e
     go n (Lam v e) | isTyVar v   = go n e
+                   | otherwise   = False
+
     go _ (Case _ _ _ alts)       = null alts
        -- See Note [Empty case alternatives] in GHC.Core
-    go _ _                       = False
+
+    go n (Var v) | isDeadEndAppSig (idDmdSig v) n = True
+                 | isEmptyTy (idType v)           = True
+                 | otherwise                      = False
 
 {- Note [Bottoming expressions]
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d22bec7cdb9ff5ac9d9a496954a09f084aaa12a6

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d22bec7cdb9ff5ac9d9a496954a09f084aaa12a6
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/20220819/2a991150/attachment-0001.html>


More information about the ghc-commits mailing list