[project @ 1997-10-19 21:41:46 by sof]
authorsof <unknown>
Sun, 19 Oct 1997 21:41:46 +0000 (21:41 +0000)
committersof <unknown>
Sun, 19 Oct 1997 21:41:46 +0000 (21:41 +0000)
Refrain from doing let-to-case conversion on binders with RHS in whnf

ghc/compiler/simplCore/SimplCore.lhs

index 8a122ef..d4617c9 100644 (file)
@@ -490,9 +490,15 @@ tidyCoreExpr (Lam (UsageBinder uv) body)
        -- some let-to-case stuff is deferred to now).
 tidyCoreExpr (Let (NonRec bndr rhs) body)
   | willBeDemanded (getIdDemandInfo bndr) && 
+    not rhs_is_whnf &&         -- Don't do it if RHS is already in WHNF
     typeOkForCase (idType bndr)
   = ASSERT( not (isPrimType (idType bndr)) )
     tidyCoreExpr (Case rhs (AlgAlts [] (BindDefault bndr body)))
+  where
+    rhs_is_whnf = case mkFormSummary rhs of
+                       VarForm -> True
+                       ValueForm -> True
+                       other -> False
 
 tidyCoreExpr (Let (NonRec bndr rhs) body)
   = tidyCoreExpr rhs           `thenTM` \ rhs' ->