[PATCH] D79391: [DSE] Remove noop stores in MSSA.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 11 10:45:33 PDT 2020
fhahn added inline comments.
================
Comment at: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1815
+ if (auto *Load = dyn_cast<LoadInst>(SI->getOperand(0))) {
+ if (Load->getPointerOperand() == SI->getOperand(1)) {
+ State.deleteDeadInstruction(SI);
----------------
zoecarver wrote:
> asbirlea wrote:
> > fhahn wrote:
> > > I think the check is not strict enough at the moment. I think we have to ensure that there are no memory-writes between the load and the store that may alias them.
> > >
> > > In the simple example below, IIUC the patch would currently incorrectly eliminate ` store i32 %a, i32* %Q`.
> > >
> > > ```
> > > define void @test(i32* %Q) {
> > > %a = load i32, i32* %Q
> > > store i32 10, i32* %Q
> > > store i32 %a, i32* %Q
> > > ret void
> > > }```
> > >
> > > In terms of MemorySSA, I think we are looking for loads that use the same MemoryDef as `KillingDef`. One simple way to check this would be getting the memoryDef of KillingDef and check if it dominates the load I think.
> > >
> > +1.
> > Please add a testcase similar to the example fhahn@ gave.
> Will do. I tried the test case and it fails. I'll need to re-write most of this patch (minus the tests). I think @fhahn's solution will work. I probably won't get to this today but I should have time this weekend.
Awesome, thanks! Feel free to let us know if you have any questions.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79391/new/
https://reviews.llvm.org/D79391
More information about the llvm-commits
mailing list