[clang] [llvm] [SimplifyCFG] Extend jump-threading to allow live local defs (PR #135079)
Yingwei Zheng via cfe-commits
cfe-commits at lists.llvm.org
Tue May 13 01:35:39 PDT 2025
================
@@ -3467,13 +3485,23 @@ static bool blockIsSimpleEnoughToThreadThrough(BasicBlock *BB) {
// live outside of the current basic block.
for (User *U : I.users()) {
Instruction *UI = cast<Instruction>(U);
- if (UI->getParent() != BB || isa<PHINode>(UI))
- return false;
+ BasicBlock *UsedInBB = UI->getParent();
+ if (UsedInBB == BB) {
+ if (isa<PHINode>(UI))
+ return false;
+ } else
+ UsedInNonLocalBlocksSet.insert(UsedInBB);
}
// Looks ok, continue checking.
}
+ for (BasicBlock *Succ : successors(BB)) {
+ BlocksSet VisitedBlocksSet;
+ if (reachesUsed(Succ, UsedInNonLocalBlocksSet, VisitedBlocksSet))
----------------
dtcxzyw wrote:
`reachesUsed` is expensive. Can we defer this DFS walk until cheap checks have been done (at line 3584)?
https://github.com/llvm/llvm-project/pull/135079
More information about the cfe-commits
mailing list