Note [Empty case is trivial]
The expression (case (x::Int) Bool of {}) is just a type-changing
case used when we are sure that 'x' will not return. See
Note [Empty case alternatives] in GHC.Core.
If the scrutinee is trivial, then so is the whole expression; and the
CoreToSTG pass in fact drops the case expression leaving only the
scrutinee.
Having more trivial expressions is good. Moreover, if we don't treat
it as trivial we may land up with let-bindings like
let v = case x of {} in ...
and after CoreToSTG that gives
let v = x in ...
and that confuses the code generator (#11155). So best to kill
it off at source. References 1
- Empty case alternatives GHC.Core
Referenced by 3
- Empty case alternatives GHC.Core
- GHC.Core.Opt.SetLevels call site
- GHC.Core.Utils call site