From 8e15cfb601a904523a39079aa7c55e729ccbffda Mon Sep 17 00:00:00 2001 From: "simonpj@microsoft.com" Date: Thu, 17 Jan 2008 10:52:56 +0000 Subject: Record evaluated-ness information correctly for strict constructors The add_evals code in Simplify.simplAlt had bit-rotted. Example: data T a = T !a data U a = U !a foo :: T a -> U a foo (T x) = U x Here we should not evaluate x before building the U result, because the x argument of T is already evaluated. Thanks to Roman for finding this. --- compiler/simplCore/SimplEnv.lhs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'compiler/simplCore/SimplEnv.lhs') diff --git a/compiler/simplCore/SimplEnv.lhs b/compiler/simplCore/SimplEnv.lhs index 762758fadf..10e243c058 100644 --- a/compiler/simplCore/SimplEnv.lhs +++ b/compiler/simplCore/SimplEnv.lhs @@ -519,18 +519,19 @@ simplBinder env bndr ------------- simplLamBndr :: SimplEnv -> Var -> SimplM (SimplEnv, Var) -- Used for lambda binders. These sometimes have unfoldings added by --- the worker/wrapper pass that must be preserved, becuase they can't +-- the worker/wrapper pass that must be preserved, because they can't -- be reconstructed from context. For example: -- f x = case x of (a,b) -> fw a b x -- fw a b x{=(a,b)} = ... -- The "{=(a,b)}" is an unfolding we can't reconstruct otherwise. simplLamBndr env bndr - | not (isId bndr && hasSomeUnfolding old_unf) = simplBinder env bndr -- Normal case - | otherwise = seqId id2 `seq` return (env', id2) + | isId bndr && hasSomeUnfolding old_unf = seqId id2 `seq` return (env2, id2) -- Special case + | otherwise = seqId id1 `seq` return (env1, id1) -- Normal case where old_unf = idUnfolding bndr - (env', id1) = substIdBndr env bndr - id2 = id1 `setIdUnfolding` substUnfolding env old_unf + (env1, id1) = substIdBndr env bndr + id2 = id1 `setIdUnfolding` substUnfolding env old_unf + env2 = modifyInScope env1 id1 id2 --------------- simplNonRecBndr :: SimplEnv -> InBndr -> SimplM (SimplEnv, OutBndr) -- cgit v1.2.1