This hopefully fixes the miscompile in issue #58883.
I'm not sure if the baseline test actually shows the expected miscompile, but the test diff does demonstrate that we gave up on store merging in that example.
This change should be strictly safe (just adds another clause to avoid the transform), and it does not prohibit any existing valid optimizations based on regression tests. I want to believe that it's also a sufficient fix (possibly overkill), but I'm not sure how to prove that.
I think this will also bail on stores that are actually not aliasing any of the stores, for instance the store to '@d' in the test case. Would it be possible to check aliasing against the full, merged store? (maybe in a separate loop further down after the offsets have been checked?)
Why are not the uses of N checked?
What about the uses of the uses... wouldn't we have to check any additional stores further down the DAG via the use edges?
Does this make a big difference? I am thinking that an alternative to bailing might be to add the correct chains from the new store to all the users..?