codeGen: Don't discard live case binders in unsafeEqualityProof logic
Previously CoreToStg would unconditionally discard cases of the form:
case unsafeEqualityProof of wild { _ -> rhs }
and rather replace the whole thing with rhs
. However, in some cases
(see #18227 (closed)) the case binder is still live, resulting in unbound
occurrences in rhs
. Fix this by only discarding the case if the case
binder is dead.
Fixes #18227 (closed).
Original patch due to @simonpj.