[PATCH] D60659: [InstCombine] Eliminate stores to constant memory
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 13 14:54:31 PDT 2019
reames created this revision.
reames added reviewers: apilipenko, skatkov, fedor.sergeev.
Herald added subscribers: bollu, mcrosier.
Herald added a project: LLVM.
If we have a store to a piece of memory which is known constant, then we know the store must be storing back the same value. As a result, the store (or memset, or memmove) must either be down a dead path, or a noop. In either case, it is valid to simply remove the store.
The motivating case for this involves a memmove to a buffer which is constant down a path which is dynamically dead.
Note that I'm choosing to implement the less aggressive of two possible semantics here. We could simply say that the store *is undefined*, and prune the path. That seemed a bit too likely to break real code in subtle ways, so I decide to just remove the store itself.
(I'm going to rebase the tests shortly, so you can ignore the spurious diffs. I'll rebase once done.)
Repository:
rL LLVM
https://reviews.llvm.org/D60659
Files:
lib/Transforms/InstCombine/InstCombineCalls.cpp
lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
test/Transforms/InstCombine/gep-custom-dl.ll
test/Transforms/InstCombine/getelementptr.ll
test/Transforms/InstCombine/memcpy.ll
test/Transforms/InstCombine/memmove.ll
test/Transforms/InstCombine/memset.ll
test/Transforms/InstCombine/store.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60659.195041.patch
Type: text/x-patch
Size: 9790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190413/0d625a1f/attachment.bin>
More information about the llvm-commits
mailing list