Skip to content

Commit d216fd1

Browse files
committed
[PredicateInfo] Don't use depth first walk (NFCI)
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.
1 parent b85387d commit d216fd1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

llvm/lib/Transforms/Utils/PredicateInfo.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -488,17 +488,19 @@ void PredicateInfoBuilder::buildPredicateInfo() {
488488
// Collect operands to rename from all conditional branch terminators, as well
489489
// as assume statements.
490490
SmallVector<Value *, 8> OpsToRename;
491-
for (auto *DTN : depth_first(DT.getRootNode())) {
492-
BasicBlock *BranchBB = DTN->getBlock();
493-
if (auto *BI = dyn_cast<BranchInst>(BranchBB->getTerminator())) {
491+
for (BasicBlock &BB : F) {
492+
if (!DT.isReachableFromEntry(&BB))
493+
continue;
494+
495+
if (auto *BI = dyn_cast<BranchInst>(BB.getTerminator())) {
494496
if (!BI->isConditional())
495497
continue;
496498
// Can't insert conditional information if they all go to the same place.
497499
if (BI->getSuccessor(0) == BI->getSuccessor(1))
498500
continue;
499-
processBranch(BI, BranchBB, OpsToRename);
500-
} else if (auto *SI = dyn_cast<SwitchInst>(BranchBB->getTerminator())) {
501-
processSwitch(SI, BranchBB, OpsToRename);
501+
processBranch(BI, &BB, OpsToRename);
502+
} else if (auto *SI = dyn_cast<SwitchInst>(BB.getTerminator())) {
503+
processSwitch(SI, &BB, OpsToRename);
502504
}
503505
}
504506
for (auto &Assume : AC.assumptions()) {

0 commit comments

Comments
 (0)