Make MergeConsecutiveStores look at other stores on same chain
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 28 Aug 2015 17:31:28 +0000 (17:31 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 28 Aug 2015 17:31:28 +0000 (17:31 +0000)
commit1350385078ebde6864a409485e2618a0e8c55bc4
tree46c27422c9b18aaa2ca1f1f0f5439d4d1331ac97
parentdc15d2d8ea86cd1fcc5eb60b21bc23e91dedf2ad
Make MergeConsecutiveStores look at other stores on same chain

When combiner AA is enabled, look at stores on the same chain.
Non-aliasing stores are moved to the same chain so the existing
code fails because it expects to find an adajcent store on a consecutive
chain.

Because of how DAGCombiner tries these store combines,
MergeConsecutiveStores doesn't see the correct set of stores on the chain
when it visits the other stores. Each store individually has its chain
fixed before trying to merge consecutive stores, and then tries to merge
stores from that point before the other stores have been processed to
have their chains fixed. To fix this, attempt to use FindBetterChain
on any possibly neighboring stores in visitSTORE.

Suppose you have 4 32-bit stores that should be merged into 1 vector
store. One store would be visited first, fixing the chain. What happens is
because not all of the store chains have yet been fixed, 2 of the stores
are merged. The other 2 stores later have their chains fixed,
but because the other stores were already merged, they have different
memory types and merging the two different sized stores is not
supported and would be more difficult to handle.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246307 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/PowerPC/memcpy-vec.ll
test/CodeGen/SystemZ/vec-args-04.ll
test/CodeGen/SystemZ/vec-args-05.ll