[commit: ghc] master: Do occurrence analysis on result of BuiltInRule (feaa095)

git at git.haskell.org git at git.haskell.org
Tue Jul 21 16:43:02 UTC 2015


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/feaa0951f5cb6d54fffc5df822c03dfcb6db0e58/ghc

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

commit feaa0951f5cb6d54fffc5df822c03dfcb6db0e58
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Tue Jul 21 14:41:08 2015 +0100

    Do occurrence analysis on result of BuiltInRule
    
    Previously we did occurrence analysis on the result of a
    non-built-in RULE, but not of a built-in one.  It makes a
    difference if the rule returns something with binders
    (which admittedly it usually does not).  I'm about to
    introduce just such a rule for 'seq'.


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

feaa0951f5cb6d54fffc5df822c03dfcb6db0e58
 compiler/specialise/Rules.hs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/compiler/specialise/Rules.hs b/compiler/specialise/Rules.hs
index 7cf6e56..f1288cc 100644
--- a/compiler/specialise/Rules.hs
+++ b/compiler/specialise/Rules.hs
@@ -483,7 +483,7 @@ matchRule :: DynFlags -> InScopeEnv -> (Activation -> Bool)
 -- then (f args) matches the rule, and the corresponding
 -- rewritten RHS is rhs
 --
--- The bndrs and rhs is occurrence-analysed
+-- The returned expression is occurrence-analysed
 --
 --      Example
 --
@@ -505,8 +505,9 @@ matchRule dflags rule_env _is_active fn args _rough_args
           (BuiltinRule { ru_try = match_fn })
 -- Built-in rules can't be switched off, it seems
   = case match_fn dflags rule_env fn args of
-        Just expr -> Just expr
         Nothing   -> Nothing
+        Just expr -> Just (occurAnalyseExpr expr)
+        -- We could do this when putting things into the rulebase, I guess
 
 matchRule _ in_scope is_active _ args rough_args
           (Rule { ru_act = act, ru_rough = tpl_tops



More information about the ghc-commits mailing list