X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fspecialise%2FRules.lhs;h=65975f81cb537372135332c1b567c558775ff8a7;hb=993ce43d3f3fb6bdb04cbc6d82babdd23355f7d7;hp=bbb678deecc1712556bc3017333bf4d09ccaed1c;hpb=609db9ce4ad70c8cf64350b75da03229a7c33b0f;p=ghc-hetmet.git diff --git a/compiler/specialise/Rules.lhs b/compiler/specialise/Rules.lhs index bbb678d..65975f8 100644 --- a/compiler/specialise/Rules.lhs +++ b/compiler/specialise/Rules.lhs @@ -35,8 +35,7 @@ import Type ( Type, TvSubstEnv ) import Coercion ( coercionKind ) import TcType ( tcSplitTyConApp_maybe ) import CoreTidy ( tidyRules ) -import Id ( Id, idUnfolding, isLocalId, isGlobalId, idName, idType, - idSpecialisation, idCoreRules, setIdSpecialisation ) +import Id import IdInfo ( SpecInfo( SpecInfo ) ) import Var ( Var ) import VarEnv @@ -233,9 +232,11 @@ getRules :: RuleBase -> Id -> [CoreRule] -- (b) rules added in subsequent modules (extra_rules) -- PrimOps, for example, are born with a bunch of rules under (a) getRules rule_base fn - | isLocalId fn = idCoreRules fn - | otherwise = WARN( null (idCoreRules fn), ppr fn <+> ppr (idCoreRules fn) ) - lookupNameEnv rule_base (idName fn) `orElse` [] + | isLocalId fn = idCoreRules fn + | otherwise = WARN( not (isPrimOpId fn) && notNull (idCoreRules fn), + ppr fn <+> ppr (idCoreRules fn) ) + idCoreRules fn ++ (lookupNameEnv rule_base (idName fn) `orElse` []) + -- Only PrimOpIds have rules inside themselves, and perhaps more besides matchRules :: (Activation -> Bool) -> InScopeSet -> Id -> [CoreExpr] @@ -267,8 +268,7 @@ findBest target (rule,ans) [] = (rule,ans) findBest target (rule1,ans1) ((rule2,ans2):prs) | rule1 `isMoreSpecific` rule2 = findBest target (rule1,ans1) prs | rule2 `isMoreSpecific` rule1 = findBest target (rule2,ans2) prs -#ifdef DEBUG - | otherwise = let pp_rule rule + | debugIsOn = let pp_rule rule | opt_PprStyle_Debug = ppr rule | otherwise = doubleQuotes (ftext (ru_name rule)) in pprTrace "Rules.findBest: rule overlap (Rule 1 wins)" @@ -278,9 +278,7 @@ findBest target (rule1,ans1) ((rule2,ans2):prs) ptext SLIT("Rule 1:") <+> pp_rule rule1, ptext SLIT("Rule 2:") <+> pp_rule rule2]) $ findBest target (rule1,ans1) prs -#else | otherwise = findBest target (rule1,ans1) prs -#endif where (fn,args) = target