[commit: ghc] master: In simpleOptExpr, unfold compulsary unfoldings (d557d8c)
git at git.haskell.org
git at git.haskell.org
Tue Feb 11 15:40:27 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/d557d8c34b80a9513b6ea36aeab6453173d83fa3/ghc
>---------------------------------------------------------------
commit d557d8c34b80a9513b6ea36aeab6453173d83fa3
Author: Joachim Breitner <mail at joachim-breitner.de>
Date: Fri Jan 24 13:35:21 2014 +0000
In simpleOptExpr, unfold compulsary unfoldings
such as that of coerce.
>---------------------------------------------------------------
d557d8c34b80a9513b6ea36aeab6453173d83fa3
compiler/coreSyn/CoreSubst.lhs | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/compiler/coreSyn/CoreSubst.lhs b/compiler/coreSyn/CoreSubst.lhs
index 8531f92..20394f2 100644
--- a/compiler/coreSyn/CoreSubst.lhs
+++ b/compiler/coreSyn/CoreSubst.lhs
@@ -966,6 +966,10 @@ simple_app subst (Lam b e) (a:as)
where
(subst', b') = subst_opt_bndr subst b
b2 = add_info subst' b b'
+simple_app subst (Var v) as
+ | isCompulsoryUnfolding (idUnfolding v)
+ -- See Note [Unfold compulsory unfoldings in LHSs]
+ = simple_app subst (unfoldingTemplate (idUnfolding v)) as
simple_app subst e as
= foldl App (simple_opt_expr subst e) as
@@ -1112,6 +1116,13 @@ we don't know what phase we're in. Here's an example
When inlining 'foo' in 'bar' we want the let-binding for 'inner'
to remain visible until Phase 1
+Note [Unfold compulsory unfoldings in LHSs]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+When the user writes `map coerce = coerce` as a rule, the rule will only ever
+match if we replace coerce by its unfolding on the LHS, because that is the
+core that the rule matching engine will find. So do that for everything that
+has a compulsory unfolding. Also see Note [Desugaring coerce as cast]
%************************************************************************
%* *
More information about the ghc-commits
mailing list