diff options
author | Joachim Breitner <mail@joachim-breitner.de> | 2018-03-21 17:02:21 -0400 |
---|---|---|
committer | Joachim Breitner <mail@joachim-breitner.de> | 2018-03-21 17:02:21 -0400 |
commit | 4a47fd33d2f16070d4fe8bd32a104587608061cd (patch) | |
tree | 204afacf3bf4177de01b8f2778f4154c26bf578b /compiler/coreSyn/CoreUtils.hs | |
parent | c663b715b6201d460e8bf2b6fb26e61c700384e0 (diff) | |
parent | 0aa7d8796a95298e906ea81fe4a52590d75c2e47 (diff) | |
download | haskell-wip/T14068.tar.gz |
Merge branch 'wip/T14951' into wip/T14068wip/T14068
Diffstat (limited to 'compiler/coreSyn/CoreUtils.hs')
-rw-r--r-- | compiler/coreSyn/CoreUtils.hs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/compiler/coreSyn/CoreUtils.hs b/compiler/coreSyn/CoreUtils.hs index 4db9d8fc29..5608afc334 100644 --- a/compiler/coreSyn/CoreUtils.hs +++ b/compiler/coreSyn/CoreUtils.hs @@ -1449,8 +1449,11 @@ app_ok primop_ok fun args -- Often there is a literal divisor, and this -- can get rid of a thunk in an inner loop + | SeqOp <- op -- See Note [seq# and expr_ok] + -> all (expr_ok primop_ok) args + | otherwise - -> primop_ok op -- Check the primop itself + -> primop_ok op -- Check the primop itself && and (zipWith arg_ok arg_tys args) -- Check the arguments _other -> isUnliftedType (idType fun) -- c.f. the Var case of exprIsHNF @@ -1607,6 +1610,25 @@ See also Note [dataToTag#] in primops.txt.pp. Bottom line: * in exprOkForSpeculation we simply ignore all lifted arguments. + * except see Note [seq# and expr_ok] for an exception + + +Note [seq# and expr_ok] +~~~~~~~~~~~~~~~~~~~~~~~ +Recall that + seq# :: forall a s . a -> State# s -> (# State# s, a #) +must always evaluate its first argument. So it's really a +counter-example to Note [Primops with lifted arguments]. In +the case of seq# we must check the argument to seq#. Remember +item (d) of the specification of exprOkForSpeculation: + + -- Precisely, it returns @True@ iff: + -- a) The expression guarantees to terminate, + ... + -- d) without throwing a Haskell exception + +The lack of this special case caused Trac #5129 to go bad again. +See comment:24 and following ************************************************************************ |