[DSE] Merge stores when the later store only writes to memory locations the early...
authorSanjay Patel <spatel@rotateright.com>
Tue, 26 Sep 2017 13:54:28 +0000 (13:54 +0000)
committerSanjay Patel <spatel@rotateright.com>
Tue, 26 Sep 2017 13:54:28 +0000 (13:54 +0000)
commit1d04b5bacf4fab305db930895a543dc42614b81f
tree13011fa2979ea0754095b6ad48245e7187f79487
parentf47c4b41840975f33153d6a817f8f45c4169bc74
[DSE] Merge stores when the later store only writes to memory locations the early store also wrote to (2nd try)

This is a 2nd attempt at:
https://reviews.llvm.org/rL310055
...which was reverted at rL310123 because of PR34074:
https://bugs.llvm.org/show_bug.cgi?id=34074

In this version, we break out of the inner loop after we successfully merge and kill a pair of stores. In the
earlier rev, we were continuing instead, which meant we could process the invalid info from a now dead store.

Original commit message (authored by Filipe Cabecinhas):

This fixes PR31777.

If both stores' values are ConstantInt, we merge the two stores
(shifting the smaller store appropriately) and replace the earlier (and
larger) store with an updated constant.

In the future we should also support vectors of integers. And maybe
float/double if we can.

Differential Revision: https://reviews.llvm.org/D30703

llvm-svn: 314206
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/test/Transforms/DeadStoreElimination/PartialStore.ll
llvm/test/Transforms/DeadStoreElimination/combined-partial-overwrites.ll
llvm/test/Transforms/DeadStoreElimination/merge-stores-big-endian.ll [new file with mode: 0644]
llvm/test/Transforms/DeadStoreElimination/merge-stores.ll [new file with mode: 0644]