summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Serrano <trupill@gmail.com>2015-07-30 10:48:55 +0200
committerAlejandro Serrano <trupill@gmail.com>2015-07-30 10:48:55 +0200
commitaa11d02b719cb6226f69220ac85f2cf8f1a66a2d (patch)
tree951f148e0f1cb559c2e8743ab798f37fbcedb584
parentc4a49d8d2baf0c051d6198e45b4c9d9b58e0fc51 (diff)
downloadhaskell-aa11d02b719cb6226f69220ac85f2cf8f1a66a2d.tar.gz
Better simplification of casts in simple_opt_expr
-rw-r--r--compiler/coreSyn/CoreSubst.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/coreSyn/CoreSubst.hs b/compiler/coreSyn/CoreSubst.hs
index f69e512ab2..6fec2cf5f3 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