Make case-merging a bit smarter
In doing some other work I tripped over code like this:
```
case <scrut> of r {
DEFAULT -> join j = <rhsj> in
case r of
A -> <rhsa>
B -> <rhsb>
C -> <rhsc>
```
We'd like to do case-merge, to have just one `case`. But we need to get that join point out of the way, like this
```
join j = <rhs> in
case <scrut> of r {
DEFAULT -> case r of
A -> <rhsa>
B -> <rhsb>
C -> <rhsc>
```
Now we can merge, to get
```
join j = <rhs> in
case <scrut> of r {
A -> <rhsa>
B -> <rhsb>
C -> <rhsc>
```
This is already implemented in `GHC.Core.Utils.mergeCaseAlts`. See `Note [Merge Nested Cases]` in that module.
**BUT what if `<rhsj>` mentions the case binder `r`?** Then we can't float the join-binding out. Boo.
## Solution
If `<scrut>` is trivial, and `j` is differnt to `r`, we can fix things up like this:
```
let r = <scrut> in
join j = <rhs> in
case r of r {
A -> <rhsa>
B -> <rhsb>
C -> <rhsc>
```
I say "if `<scrut>` is trivial" because I don't want to build a new thunk for `r`.
issue