Skip to content

Commit

Permalink
[LoopInfo] Avoid redundant DomTree lookup (NFC)
Browse files Browse the repository at this point in the history
For Header we already have the DomTreeNode. For Backedge, fetch it
only once.
  • Loading branch information
nikic committed Nov 21, 2023
1 parent 775d2f3 commit ff75121
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions llvm/include/llvm/Support/GenericLoopInfoImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -581,10 +581,9 @@ void LoopInfoBase<BlockT, LoopT>::analyze(const DomTreeBase<BlockT> &DomTree) {
// Check each predecessor of the potential loop header.
for (const auto Backedge : children<Inverse<BlockT *>>(Header)) {
// If Header dominates predBB, this is a new loop. Collect the backedges.
if (DomTree.dominates(Header, Backedge) &&
DomTree.isReachableFromEntry(Backedge)) {
const DomTreeNodeBase<BlockT> *BackedgeNode = DomTree.getNode(Backedge);
if (BackedgeNode && DomTree.dominates(DomNode, BackedgeNode))
Backedges.push_back(Backedge);
}
}
// Perform a backward CFG traversal to discover and map blocks in this loop.
if (!Backedges.empty()) {
Expand Down

0 comments on commit ff75121

Please sign in to comment.