[DAGCombine] Fix getStoreMergeAndAliasCandidates's AA-enabled chain walking
authorHal Finkel <hfinkel@anl.gov>
Mon, 28 Sep 2015 08:02:14 +0000 (08:02 +0000)
committerHal Finkel <hfinkel@anl.gov>
Mon, 28 Sep 2015 08:02:14 +0000 (08:02 +0000)
commit76dfa416156da9fd30e173fb0e97a98c6965bd08
tree4850eeb6c7245ba0ddc551a1357a16159f737a89
parent273cdae7e91c1b11ae9f55c6a78b1e9d820b9ea9
[DAGCombine] Fix getStoreMergeAndAliasCandidates's AA-enabled chain walking

When AA is being used, non-aliasing stores are canonicalized to use the same
chain, and DAGCombiner::getStoreMergeAndAliasCandidates can take advantage of
this by looking only as users of a store's chain operand. However, user
iteration is not result-number specific, we need to check that the use is as a
chain operand, and not via some other operand. It is certainly possible to have
another potentially-aliasing store, which shares the first's base pointer, and
uses the first's chain's node via some other operand.

Failure to catch this situation caused, at least in the included test case, an
assert later because the relative sequence-number ordering caused later
replacement to create a cycle in the DAG.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248698 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/PowerPC/merge-st-chain-op.ll [new file with mode: 0644]