[llvm-branch-commits] [llvm] 03cf88f - [DSE] Extract a common PDT check (NFC)
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Feb 28 10:55:01 PST 2022
Author: Nikita Popov
Date: 2022-02-28T10:53:06-08:00
New Revision: 03cf88fc94da55b989f1c14cb0460777834749c0
URL: https://github.com/llvm/llvm-project/commit/03cf88fc94da55b989f1c14cb0460777834749c0
DIFF: https://github.com/llvm/llvm-project/commit/03cf88fc94da55b989f1c14cb0460777834749c0.diff
LOG: [DSE] Extract a common PDT check (NFC)
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 ae636e7b61f72..8739ddce91606 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1508,54 +1508,49 @@ struct DSEState {
CommonPred = PDT.findNearestCommonDominator(CommonPred, BB);
}
- // If CommonPred is in the set of killing blocks, just check if it
- // post-dominates MaybeDeadAccess.
- if (KillingBlocks.count(CommonPred)) {
- if (PDT.dominates(CommonPred, MaybeDeadAccess->getBlock()))
- return {MaybeDeadAccess};
- return None;
- }
-
// If the common post-dominator does not post-dominate MaybeDeadAccess,
// there is a path from MaybeDeadAccess to an exit not going through a
// killing block.
- if (PDT.dominates(CommonPred, MaybeDeadAccess->getBlock())) {
- SetVector<BasicBlock *> WorkList;
-
- // If CommonPred is null, there are multiple exits from the function.
- // They all have to be added to the worklist.
- if (CommonPred)
- WorkList.insert(CommonPred);
- else
- for (BasicBlock *R : PDT.roots())
- WorkList.insert(R);
-
- NumCFGTries++;
- // Check if all paths starting from an exit node go through one of the
- // killing blocks before reaching MaybeDeadAccess.
- for (unsigned I = 0; I < WorkList.size(); I++) {
- NumCFGChecks++;
- BasicBlock *Current = WorkList[I];
- if (KillingBlocks.count(Current))
- continue;
- if (Current == MaybeDeadAccess->getBlock())
- return None;
+ if (!PDT.dominates(CommonPred, MaybeDeadAccess->getBlock()))
+ return None;
- // MaybeDeadAccess is reachable from the entry, so we don't have to
- // explore unreachable blocks further.
- if (!DT.isReachableFromEntry(Current))
- continue;
+ // If CommonPred itself is in the set of killing blocks, we're done.
+ if (KillingBlocks.count(CommonPred))
+ return {MaybeDeadAccess};
- for (BasicBlock *Pred : predecessors(Current))
- WorkList.insert(Pred);
+ SetVector<BasicBlock *> WorkList;
- if (WorkList.size() >= MemorySSAPathCheckLimit)
- return None;
- }
- NumCFGSuccess++;
- return {MaybeDeadAccess};
+ // If CommonPred is null, there are multiple exits from the function.
+ // They all have to be added to the worklist.
+ if (CommonPred)
+ WorkList.insert(CommonPred);
+ else
+ for (BasicBlock *R : PDT.roots())
+ WorkList.insert(R);
+
+ NumCFGTries++;
+ // Check if all paths starting from an exit node go through one of the
+ // killing blocks before reaching MaybeDeadAccess.
+ for (unsigned I = 0; I < WorkList.size(); I++) {
+ NumCFGChecks++;
+ BasicBlock *Current = WorkList[I];
+ if (KillingBlocks.count(Current))
+ continue;
+ if (Current == MaybeDeadAccess->getBlock())
+ return None;
+
+ // MaybeDeadAccess is reachable from the entry, so we don't have to
+ // explore unreachable blocks further.
+ if (!DT.isReachableFromEntry(Current))
+ continue;
+
+ for (BasicBlock *Pred : predecessors(Current))
+ WorkList.insert(Pred);
+
+ if (WorkList.size() >= MemorySSAPathCheckLimit)
+ return None;
}
- return None;
+ NumCFGSuccess++;
}
// No aliasing MemoryUses of MaybeDeadAccess found, MaybeDeadAccess is
More information about the llvm-branch-commits
mailing list