Skip to content

Demand: retry# should have exnDiv, not botDiv

Here's the entry in primops.txt.pp:

-- NB: retry#'s strictness information specifies it to diverge.
-- This lets the compiler perform some extra simplifications, since retry#
-- will technically never return.
--
-- This allows the simplifier to replace things like:
--   case retry# s1
--     (# s2, a #) -> e
-- with:
--   retry# s1
-- where 'e' would be unreachable anyway.  See #8091.
primop  RetryOp "retry#" GenPrimOp
   State# RealWorld -> (# State# RealWorld, v #)
   with
   strictness  = { \ _arity -> mkClosedDmdSig [topDmd] botDiv }
   out_of_line = True
   has_side_effects = True

This use of botDiv is unsound because it appears that the whole computation is strict in every free variable.

We have introduced exnDiv for exactly this reason: To enable dead-code elimination while not being strict in free variables. Let's use it on retry#, too.

retry# kind of is like a precise exception primop anyway (with a pre-defined catch handler), so it makes a lot of sense to treat it as such.

There's more context about exnDiv in Note [Dead ends] and Note [Precise exceptions and strictness analysis].

Edited by Sebastian Graf
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information