aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/PredicateInfo.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2025-06-23 09:09:19 +0200
committerGitHub <noreply@github.com>2025-06-23 09:09:19 +0200
commitc6be4ff0c8966c4dbe1cbac9a071762982a70651 (patch)
tree192af451b48f35c8c8768b85b30cc348fa94a19b /llvm/lib/Transforms/Utils/PredicateInfo.cpp
parentfccc6ee7021811a27ab1303d19407f703853ab92 (diff)
downloadllvm-c6be4ff0c8966c4dbe1cbac9a071762982a70651.zip
llvm-c6be4ff0c8966c4dbe1cbac9a071762982a70651.tar.gz
llvm-c6be4ff0c8966c4dbe1cbac9a071762982a70651.tar.bz2
[PredicateInfo] Don't use depth first walk (NFCI) (#145016)
The order in which we collect the predicates does not matter, as they will be sorted anyway. As such, avoid the expensive depth first walk over the dominator tree and instead use plain iteration over the function. (To be a bit more precise, the predicates and uses for a specific value are sorted, so this change has no impact on that. It can change the order in which values are processed in the first place, but that order is not semantically relevant.)
Diffstat (limited to 'llvm/lib/Transforms/Utils/PredicateInfo.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/PredicateInfo.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Utils/PredicateInfo.cpp b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
index 97f13e3..b57d419 100644
--- a/llvm/lib/Transforms/Utils/PredicateInfo.cpp
+++ b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
@@ -453,17 +453,19 @@ void PredicateInfoBuilder::buildPredicateInfo() {
// Collect operands to rename from all conditional branch terminators, as well
// as assume statements.
SmallVector<Value *, 8> OpsToRename;
- for (auto *DTN : depth_first(DT.getRootNode())) {
- BasicBlock *BranchBB = DTN->getBlock();
- if (auto *BI = dyn_cast<BranchInst>(BranchBB->getTerminator())) {
+ for (BasicBlock &BB : F) {
+ if (!DT.isReachableFromEntry(&BB))
+ continue;
+
+ if (auto *BI = dyn_cast<BranchInst>(BB.getTerminator())) {
if (!BI->isConditional())
continue;
// Can't insert conditional information if they all go to the same place.
if (BI->getSuccessor(0) == BI->getSuccessor(1))
continue;
- processBranch(BI, BranchBB, OpsToRename);
- } else if (auto *SI = dyn_cast<SwitchInst>(BranchBB->getTerminator())) {
- processSwitch(SI, BranchBB, OpsToRename);
+ processBranch(BI, &BB, OpsToRename);
+ } else if (auto *SI = dyn_cast<SwitchInst>(BB.getTerminator())) {
+ processSwitch(SI, &BB, OpsToRename);
}
}
for (auto &Assume : AC.assumptions()) {