From bea2ece06bbeab1d8abbde420b2fff383edd34be Mon Sep 17 00:00:00 2001 From: "simonpj@microsoft.com" Date: Fri, 2 Feb 2007 17:35:27 +0000 Subject: [PATCH] Look through Notes when generating and matching RULES --- compiler/specialise/Rules.lhs | 10 ++++++++++ compiler/specialise/SpecConstr.lhs | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/compiler/specialise/Rules.lhs b/compiler/specialise/Rules.lhs index 35b44ab..b3c9791 100644 --- a/compiler/specialise/Rules.lhs +++ b/compiler/specialise/Rules.lhs @@ -423,6 +423,16 @@ match menv subst (Var v1) e2 | Just subst <- match_var menv subst v1 e2 = Just subst +match menv subst e1 (Note n e2) + = match menv subst e1 e2 + -- Note [Notes in RULE matching] + -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + -- Look through Notes. In particular, we don't want to + -- be confused by InlineMe notes. Maybe we should be more + -- careful about profiling notes, but for now I'm just + -- riding roughshod over them. + --- See Note [Notes in call patterns] in SpecConstr + -- Here is another important rule: if the term being matched is a -- variable, we expand it so long as its unfolding is a WHNF -- (Its occurrence information is not necessarily up to date, diff --git a/compiler/specialise/SpecConstr.lhs b/compiler/specialise/SpecConstr.lhs index 92e4131..99d51f1 100644 --- a/compiler/specialise/SpecConstr.lhs +++ b/compiler/specialise/SpecConstr.lhs @@ -925,6 +925,15 @@ argToPat :: InScopeEnv -- What's in scope at the fn defn site argToPat in_scope con_env arg@(Type ty) arg_occ = return (False, arg) +argToPat in_scope con_env (Note n arg) arg_occ + = argToPat in_scope con_env arg arg_occ + -- Note [Notes in call patterns] + -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + -- Ignore Notes. In particular, we want to ignore any InlineMe notes + -- Perhaps we should not ignore profiling notes, but I'm going to + -- ride roughshod over them all for now. + --- See Note [Notes in RULE matching] in Rules + argToPat in_scope con_env (Let _ arg) arg_occ = argToPat in_scope con_env arg arg_occ -- Look through let expressions -- 1.7.10.4