[commit: ghc] master: Tiny refactoring, plus comments; no change in behaviour (d3fafbb)

git at git.haskell.org git at git.haskell.org
Thu Aug 7 08:55:29 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/d3fafbb0e37bf052f63ba0d4af0c40ff03a81a2c/ghc

>---------------------------------------------------------------

commit d3fafbb0e37bf052f63ba0d4af0c40ff03a81a2c
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri Aug 1 16:39:47 2014 +0100

    Tiny refactoring, plus comments; no change in behaviour


>---------------------------------------------------------------

d3fafbb0e37bf052f63ba0d4af0c40ff03a81a2c
 compiler/prelude/PrimOp.lhs | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/compiler/prelude/PrimOp.lhs b/compiler/prelude/PrimOp.lhs
index 1261d87..4a243bc 100644
--- a/compiler/prelude/PrimOp.lhs
+++ b/compiler/prelude/PrimOp.lhs
@@ -404,9 +404,9 @@ Note [primOpOkForSpeculation]
     let-bind a can_fail or has_side_effects primop.  The RHS of a
     let-binding (which can float in and out freely) satisfies
     exprOkForSpeculation.  And exprOkForSpeculation is false of
-    can_fail and no_side_effect.
+    can_fail and has_side_effects.
 
-  * So can_fail and no_side_effect primops will appear only as the
+  * So can_fail and has_side_effects primops will appear only as the
     scrutinees of cases, and that's why the FloatIn pass is capable
     of floating case bindings inwards.
 
@@ -422,10 +422,14 @@ primOpCanFail :: PrimOp -> Bool
 #include "primop-can-fail.hs-incl"
 
 primOpOkForSpeculation :: PrimOp -> Bool
-  -- See Note [primOpOkForSpeculation and primOpOkForFloatOut]
+  -- See Note [primOpOkForSpeculation]
   -- See comments with CoreUtils.exprOkForSpeculation
+  -- primOpOkForSpeculation => primOpOkForSideEffects
 primOpOkForSpeculation op
-  = not (primOpHasSideEffects op || primOpOutOfLine op || primOpCanFail op)
+  =  primOpOkForSideEffects op
+  && not (primOpOutOfLine op || primOpCanFail op)
+    -- I think the "out of line" test is because out of line things can
+    -- be expensive (eg sine, consine), and so we may not want to speculate them
 
 primOpOkForSideEffects :: PrimOp -> Bool
 primOpOkForSideEffects op



More information about the ghc-commits mailing list