[llvm] 42c57c2 - [DSE, MemorySSA] Simplify code, EarlierAccess is be a MemoryDef (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 30 13:33:00 PDT 2020
Author: Florian Hahn
Date: 2020-08-30T21:31:57+01:00
New Revision: 42c57c294dfbd8ea82cd61c709289480f513211b
URL: https://github.com/llvm/llvm-project/commit/42c57c294dfbd8ea82cd61c709289480f513211b
DIFF: https://github.com/llvm/llvm-project/commit/42c57c294dfbd8ea82cd61c709289480f513211b.diff
LOG: [DSE,MemorySSA] Simplify code, EarlierAccess is be a MemoryDef (NFC).
After recent changes, we return early if Current is a MemoryPhi, so
EarlierAccess can only be a MemoryDef.
Added:
Modified:
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 9825dfdf01cd..b2613697bfa5 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1935,24 +1935,17 @@ struct DSEState {
}
} while (StepAgain);
- MemoryAccess *EarlierAccess = Current;
// Accesses to objects accessible after the function returns can only be
// eliminated if the access is killed along all paths to the exit. Collect
// the blocks with killing (=completely overwriting MemoryDefs) and check if
// they cover all paths from EarlierAccess to any function exit.
SmallPtrSet<Instruction *, 16> KillingDefs;
KillingDefs.insert(KillingDef->getMemoryInst());
+ MemoryAccess *EarlierAccess = Current;
Instruction *EarlierMemInst =
- isa<MemoryDef>(EarlierAccess)
- ? cast<MemoryDef>(EarlierAccess)->getMemoryInst()
- : nullptr;
- LLVM_DEBUG({
- dbgs() << " Checking for reads of " << *EarlierAccess;
- if (EarlierMemInst)
- dbgs() << " (" << *EarlierMemInst << ")\n";
- else
- dbgs() << ")\n";
- });
+ cast<MemoryDef>(EarlierAccess)->getMemoryInst();
+ LLVM_DEBUG(dbgs() << " Checking for reads of " << *EarlierAccess << " ("
+ << *EarlierMemInst << ")\n");
SmallSetVector<MemoryAccess *, 32> WorkList;
auto PushMemUses = [&WorkList](MemoryAccess *Acc) {
@@ -1964,7 +1957,7 @@ struct DSEState {
// Optimistically collect all accesses for reads. If we do not find any
// read clobbers, add them to the cache.
SmallPtrSet<MemoryAccess *, 16> KnownNoReads;
- if (!EarlierMemInst || !EarlierMemInst->mayReadFromMemory())
+ if (!EarlierMemInst->mayReadFromMemory())
KnownNoReads.insert(EarlierAccess);
// Check if EarlierDef may be read.
for (unsigned I = 0; I < WorkList.size(); I++) {
More information about the llvm-commits
mailing list