Simple optimizer can create nested casts
As discussed on the ghc-devs list, the simple optimizer can create nested casts. For example, if we start with
let { y = x `cast` co1 } in y `cast` co2
then y
will be inlined to get (x `cast` co1) `cast` co2
. We expect to get x `cast` co1; co2
, but the simple optimizer does not use mkCast
to reconstruct casts, so the nesting is not eliminated.
This is not very important, since the simplifier will eliminate the nesting anyway, but it can cause some unnecessary noise in the output of -ddump-ds
, so it would be nice to fix. (The patch is very simple, so I’ll open an MR with the fix.)