Bug in DAG combine?

I think DAG combine misses to check the address space when eliminating a store in one optimization case that I’ve filed as https://bugs.llvm.org/show_bug.cgi?id=50267.

A suggested fix is https://reviews.llvm.org/D102096.

I’ve attached a test case for x86 to the bug and patch, though it should affect all backends. A simple reproducer is this: https://www.godbolt.org/z/deT9d7z4K.

I believe that DAG combine should not eliminate a store at this point. Though the pointer values might be the same, the address space may have been different, so it should be left to the target’s backend. Most likely, such stores would end up as different instructions.

If somebody could review this that would be great, thanks in advance.