Skip to content

Commit 16b1f65

Browse files
committed
If we determine a block reaches non-local uses, record that result.
Signed-off-by: John Lu <John.Lu@amd.com>
1 parent 525f2fa commit 16b1f65

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3457,17 +3457,17 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI,
34573457

34583458
using BlocksSet = SmallPtrSet<BasicBlock *, 8>;
34593459

3460-
static bool reachesUsed(BasicBlock *BB,
3461-
const BlocksSet &UsedInNonLocalBlocksSet,
3460+
static bool reachesUsed(BasicBlock *BB, BlocksSet &ReachesNonLocalUses,
34623461
BlocksSet &VisitedBlocksSet) {
3462+
if (ReachesNonLocalUses.contains(BB))
3463+
return true;
34633464
if (!VisitedBlocksSet.insert(BB).second)
34643465
return false;
3465-
3466-
if (UsedInNonLocalBlocksSet.contains(BB))
3467-
return true;
34683466
for (BasicBlock *Succ : successors(BB))
3469-
if (reachesUsed(Succ, UsedInNonLocalBlocksSet, VisitedBlocksSet))
3467+
if (reachesUsed(Succ, ReachesNonLocalUses, VisitedBlocksSet)) {
3468+
ReachesNonLocalUses.insert(BB);
34703469
return true;
3470+
}
34713471
return false;
34723472
}
34733473

@@ -3565,8 +3565,8 @@ foldCondBranchOnValueKnownInPredecessorImpl(BranchInst *BI, DomTreeUpdater *DTU,
35653565
// Check that the block is small enough and record which non-local blocks use
35663566
// values defined in the block.
35673567

3568-
BlocksSet UsedInNonLocalBlocksSet;
3569-
if (!blockIsSimpleEnoughToThreadThrough(BB, UsedInNonLocalBlocksSet))
3568+
BlocksSet ReachesNonLocalUses;
3569+
if (!blockIsSimpleEnoughToThreadThrough(BB, ReachesNonLocalUses))
35703570
return false;
35713571

35723572
for (const auto &Pair : KnownValues) {
@@ -3587,7 +3587,7 @@ foldCondBranchOnValueKnownInPredecessorImpl(BranchInst *BI, DomTreeUpdater *DTU,
35873587

35883588
// Only revector to RealDest if no values defined in BB are live.
35893589
BlocksSet VisitedBlocksSet;
3590-
if (reachesUsed(RealDest, UsedInNonLocalBlocksSet, VisitedBlocksSet))
3590+
if (reachesUsed(RealDest, ReachesNonLocalUses, VisitedBlocksSet))
35913591
continue;
35923592

35933593
LLVM_DEBUG({

0 commit comments

Comments
 (0)