[commit: ghc] wip/impredicativity: Better simplification of casts in simple_opt_expr (aa11d02)

git at git.haskell.org git at git.haskell.org
Thu Jul 30 10:18:32 UTC 2015


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

On branch  : wip/impredicativity
Link       : http://ghc.haskell.org/trac/ghc/changeset/aa11d02b719cb6226f69220ac85f2cf8f1a66a2d/ghc

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

commit aa11d02b719cb6226f69220ac85f2cf8f1a66a2d
Author: Alejandro Serrano <trupill at gmail.com>
Date:   Thu Jul 30 10:48:55 2015 +0200

    Better simplification of casts in simple_opt_expr


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

aa11d02b719cb6226f69220ac85f2cf8f1a66a2d
 compiler/coreSyn/CoreSubst.hs | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/compiler/coreSyn/CoreSubst.hs b/compiler/coreSyn/CoreSubst.hs
index f69e512..6fec2cf 100644
--- a/compiler/coreSyn/CoreSubst.hs
+++ b/compiler/coreSyn/CoreSubst.hs
@@ -1035,9 +1035,11 @@ simple_cast subst (Cast e e_co)
   = go e e_co
   where
     go (Cast e e_co) co = go e (mkTransCo e_co co)
-    go e co | isReflCo co' = simple_opt_expr subst e
-            | otherwise    = Cast (simple_opt_expr subst e) co'
-            where co' = optCoercion (getCvSubst subst) co
+    go e co = case simple_opt_expr subst e of
+                e'@(Cast _ _)     -> go e' co
+                e' | isReflCo co' -> e'
+                   | otherwise    -> Cast e' co'
+                   where co' = optCoercion (getCvSubst subst) co
 
 simple_cast subst e
   = simple_opt_expr subst e



More information about the ghc-commits mailing list