Skip to content

Commit c6be4ff

Browse files
authored
[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.)
1 parent fccc6ee commit c6be4ff

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
@@ -453,17 +453,19 @@ void PredicateInfoBuilder::buildPredicateInfo() {
453453
// Collect operands to rename from all conditional branch terminators, as well
454454
// as assume statements.
455455
SmallVector<Value *, 8> OpsToRename;
456-
for (auto *DTN : depth_first(DT.getRootNode())) {
457-
BasicBlock *BranchBB = DTN->getBlock();
458-
if (auto *BI = dyn_cast<BranchInst>(BranchBB->getTerminator())) {
456+
for (BasicBlock &BB : F) {
457+
if (!DT.isReachableFromEntry(&BB))
458+
continue;
459+
460+
if (auto *BI = dyn_cast<BranchInst>(BB.getTerminator())) {
459461
if (!BI->isConditional())
460462
continue;
461463
// Can't insert conditional information if they all go to the same place.
462464
if (BI->getSuccessor(0) == BI->getSuccessor(1))
463465
continue;
464-
processBranch(BI, BranchBB, OpsToRename);
465-
} else if (auto *SI = dyn_cast<SwitchInst>(BranchBB->getTerminator())) {
466-
processSwitch(SI, BranchBB, OpsToRename);
466+
processBranch(BI, &BB, OpsToRename);
467+
} else if (auto *SI = dyn_cast<SwitchInst>(BB.getTerminator())) {
468+
processSwitch(SI, &BB, OpsToRename);
467469
}
468470
}
469471
for (auto &Assume : AC.assumptions()) {

0 commit comments

Comments
 (0)