https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119033
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- Andrew analyzed it quite well. This is the old issue of propagating conditional equivalences which we have quite some (duplicate) bugs about. I don't see how we can preserve provenance with the replacement. The only improvement we can make is to statically fold the compare, but then we can hide the address expressions so we get the folding done early but expose them after inlining. Note doing the compare in an integer type isn't even necessary as equality compares are valid across object boundaries, so we can't mitigate this by avoiding the replacement only when we see a cast here. Likewise avoiding copy replacement for pointers only wouldn't work since the conditional could be full integer and then cast to a pointer outside. What could be done would be completely re-do how we treat provenance across integer types and not remove pointer <-> integer type roundtrips. But that's a change pessimizing pointer analysis quite a bit since all pointer to integer conversions become escape points then. We could in theory try to be more clever here, but currently I lack motivation to do that. The only cases that create actual problems are artificial problems sofar.