From: simonpj Date: Thu, 4 Jan 2001 08:42:21 +0000 (+0000) Subject: [project @ 2001-01-04 08:42:21 by simonpj] X-Git-Tag: Approximately_9120_patches~2972 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=790dea010e6068a0be319562858495273a94fcf3;p=ghc-hetmet.git [project @ 2001-01-04 08:42:21 by simonpj] Allow rules to apply for loop-breakers. This backs out the previous (bogus) change. There's a comment in Simplify.completeCall that explains. --- diff --git a/ghc/compiler/simplCore/Simplify.lhs b/ghc/compiler/simplCore/Simplify.lhs index 4683370..76da6e5 100644 --- a/ghc/compiler/simplCore/Simplify.lhs +++ b/ghc/compiler/simplCore/Simplify.lhs @@ -810,14 +810,21 @@ completeCall var occ_info cont -- won't occur for things that have specialisations till a later phase, so -- it's ok to try for inlining first. -- - -- Don't apply rules for a loop breaker: doing so might give rise - -- to an infinite loop, for the same reasons that inlining the ordinary - -- RHS of a loop breaker might. + -- You might think that we shouldn't apply rules for a loop breaker: + -- doing so might give rise to an infinite loop, because a RULE is + -- rather like an extra equation for the function: + -- RULE: f (g x) y = x+y + -- Eqn: f a y = a-y + -- + -- But it's too drastic to disable rules for loop breakers. + -- Even the foldr/build rule would be disabled, because foldr + -- is recursive, and hence a loop breaker: + -- foldr k z (build g) = g k z + -- So it's up to the programmer: rules can cause divergence getSwitchChecker `thenSmpl` \ chkr -> let - maybe_rule | switchIsOn chkr DontApplyRules - || isLoopBreaker occ_info = Nothing + maybe_rule | switchIsOn chkr DontApplyRules = Nothing | otherwise = lookupRule in_scope var args' in case maybe_rule of {