https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101641
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- Just some more brain-dumps from thinking about a fix. - we can annotate the alias_set_entry with a flag whether it was created for a union type and use that to improve the logic - we can introduce some dynamic-type change IL elements that would allow us to elide all those redundant stores but preserve their effect. They'd be modeled as stores but would generate no code. The stored value would be implicit so we can readily remove the load (or constant). An internal function call like we have for masked stores would be a possibility but those would be quite disruptive to passes compared to the load/store sequence, so preserving the original store but with a special RHS seems most logical (but we cannot use RHS == LHS as that's only valid GIMPLE for non-register-types). We'd also have to be careful to not treat those "stores" as kills which leans towards the IFN again. A fix along the first idea looks least intrusive for backporting. A fix along the second idea looks best for recovering lost redundant store removal.