From cd6d99c5f243b8c129fb2494bbd13b4bf98abda6 Mon Sep 17 00:00:00 2001 From: simonpj Date: Tue, 20 Mar 2001 12:37:25 +0000 Subject: [PATCH] [project @ 2001-03-20 12:37:25 by simonpj] ------------------------------------- Be less keen about inlining primops ------------------------------------- Marcin pointed out that it's bad to take let x = a +# (b *# c) in x + f x + g x and inline x to get (a +# (b *# c)) + f (a +# (b *# c)) + g (a +# (b *# c)) Yet that's just what we were doing. The offending clause is in PrimOp.primOpIsCheap, which regards some primop applications as 'cheap' (and hence freely duplicable). For now, I've made it return False. Let's see what that does. --- ghc/compiler/prelude/PrimOp.lhs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ghc/compiler/prelude/PrimOp.lhs b/ghc/compiler/prelude/PrimOp.lhs index e5c1727..f96617d 100644 --- a/ghc/compiler/prelude/PrimOp.lhs +++ b/ghc/compiler/prelude/PrimOp.lhs @@ -363,7 +363,7 @@ See also @primOpIsCheap@ (below). primOpOkForSpeculation :: PrimOp -> Bool -- See comments with CoreUtils.exprOkForSpeculation primOpOkForSpeculation op - = primOpIsCheap op && not (primOpCanFail op) + = not (primOpHasSideEffects op || primOpOutOfLine op || primOpCanFail op) \end{code} @@ -376,8 +376,9 @@ than once. Evaluation order is unaffected. \begin{code} primOpIsCheap :: PrimOp -> Bool - -- See comments with CoreUtils.exprOkForSpeculation -primOpIsCheap op = not (primOpHasSideEffects op || primOpOutOfLine op) +primOpIsCheap op = False + -- March 2001: be less eager to inline PrimOps + -- Was: not (primOpHasSideEffects op || primOpOutOfLine op) \end{code} primOpIsDupable -- 1.7.10.4