Fix two issues in MergeConsecutiveStores:
authorJames Y Knight <jyknight@google.com>
Mon, 2 Nov 2015 18:48:08 +0000 (18:48 +0000)
committerJames Y Knight <jyknight@google.com>
Mon, 2 Nov 2015 18:48:08 +0000 (18:48 +0000)
commit74615f55487cfa257486d606a404f608a264de0c
treeace4de711edb423c4113bce993541d459758fd78
parent059184ab5ef06f0d63cf8e77e9126df70f9c6265
Fix two issues in MergeConsecutiveStores:

1) PR25154. This is basically a repeat of PR18102, which was fixed in
r200201, and broken again by r234430. The latter changed which of the
store nodes was merged into from the first to the last. Thus, we now
also need to prefer merging a later store at a given address into the
target node, instead of an earlier one.

2) While investigating that, I also realized I'd introduced a bug in
r236850. There, I removed a check for alignment -- not realizing that
nothing except the alignment check was ensuring that none of the stores
were overlapping! This is a really bogus way to ensure there's no
aliased stores.

A better solution to both of these issues is likely to always use the
code added in the 'if (UseAA)' branches which rearrange the chain based
on a more principled analysis. I'll look into whether that can be used
always, but in the interest of getting things back to working, I think a
minimal change makes sense.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251816 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/X86/MergeConsecutiveStores.ll
test/CodeGen/X86/dag-merge-fast-accesses.ll
test/CodeGen/X86/stores-merging.ll