Skip to content

Commit 33c8c0e

Browse files
committed
[AMDGPU] Call isLoopExiting for blocks in the loop.
isLoopExiting should only be called for blocks in the loop. A follow up patch makes this requirement an assertion. I've updated the usage here, to only match for actual exit blocks. Previously, it would also match blocks not in the loop. Reviewers: arsenm, nhaehnle Reviewed By: nhaehnle Differential Revision: https://reviews.llvm.org/D63980 llvm-svn: 364750
1 parent d5c3e34 commit 33c8c0e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ void AMDGPUTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
117117
// Add a small bonus for each of such "if" statements.
118118
if (const BranchInst *Br = dyn_cast<BranchInst>(&I)) {
119119
if (UP.Threshold < MaxBoost && Br->isConditional()) {
120-
if (L->isLoopExiting(Br->getSuccessor(0)) ||
121-
L->isLoopExiting(Br->getSuccessor(1)))
120+
BasicBlock *Succ0 = Br->getSuccessor(0);
121+
BasicBlock *Succ1 = Br->getSuccessor(1);
122+
if ((L->contains(Succ0) && L->isLoopExiting(Succ0)) ||
123+
(L->contains(Succ1) && L->isLoopExiting(Succ1)))
122124
continue;
123125
if (dependsOnLocalPhi(L, Br->getCondition())) {
124126
UP.Threshold += UnrollThresholdIf;

0 commit comments

Comments
 (0)