From 33406b8c7668247e52cb6260297640b9df4e9e1b Mon Sep 17 00:00:00 2001 From: "simonpj@microsoft.com" Date: Thu, 10 Aug 2006 14:20:34 +0000 Subject: [PATCH] Add an IAmDead case to postInlineUnconditionally, and comments --- compiler/simplCore/SimplUtils.lhs | 5 +++++ compiler/simplCore/Simplify.lhs | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/simplCore/SimplUtils.lhs b/compiler/simplCore/SimplUtils.lhs index 9e1be6d..693644f 100644 --- a/compiler/simplCore/SimplUtils.lhs +++ b/compiler/simplCore/SimplUtils.lhs @@ -748,6 +748,11 @@ postInlineUnconditionally env top_lvl bndr occ_info rhs unfolding -- int_cxt to prevent us inlining inside a lambda without some -- good reason. See the notes on int_cxt in preInlineUnconditionally + IAmDead -> True -- This happens; for example, the case_bndr during case of + -- known constructor: case (a,b) of x { (p,q) -> ... } + -- Here x isn't mentioned in the RHS, so we don't want to + -- create the (dead) let-binding let x = (a,b) in ... + other -> False -- Here's an example that we don't handle well: diff --git a/compiler/simplCore/Simplify.lhs b/compiler/simplCore/Simplify.lhs index 09f9c4c..17a6bcc 100644 --- a/compiler/simplCore/Simplify.lhs +++ b/compiler/simplCore/Simplify.lhs @@ -365,7 +365,9 @@ simplNonRecX env bndr new_rhs thing_inside returnSmpl (emptyFloats env, Case new_rhs bndr' (exprType body') [(DEFAULT, [], body')]) {- No, no, no! Do not try preInlineUnconditionally - | preInlineUnconditionally env NotTopLevel bndr new_rhs + Doing so risks exponential behaviour, because new_rhs has been simplified once already + In the cases described by the folowing commment, postInlineUnconditionally will + catch many of the relevant cases. -- This happens; for example, the case_bndr during case of -- known constructor: case (a,b) of x { (p,q) -> ... } -- Here x isn't mentioned in the RHS, so we don't want to @@ -374,6 +376,7 @@ simplNonRecX env bndr new_rhs thing_inside -- Similarly, single occurrences can be inlined vigourously -- e.g. case (f x, g y) of (a,b) -> .... -- If a,b occur once we can avoid constructing the let binding for them. + | preInlineUnconditionally env NotTopLevel bndr new_rhs = thing_inside (extendIdSubst env bndr (DoneEx new_rhs)) -} -- 1.7.10.4