]> granicus.if.org Git - llvm/commitdiff
[AMDGPU] Call isLoopExiting for blocks in the loop.
authorFlorian Hahn <flo@fhahn.com>
Mon, 1 Jul 2019 12:36:44 +0000 (12:36 +0000)
committerFlorian Hahn <flo@fhahn.com>
Mon, 1 Jul 2019 12:36:44 +0000 (12:36 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364750 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp

index 1c17e6054f035d52c6641e6fae01ad8bc617e37f..e198a9c7eb84cf7cd2fd0d79a429a135edff8ce9 100644 (file)
@@ -117,8 +117,10 @@ void AMDGPUTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
       // Add a small bonus for each of such "if" statements.
       if (const BranchInst *Br = dyn_cast<BranchInst>(&I)) {
         if (UP.Threshold < MaxBoost && Br->isConditional()) {
-          if (L->isLoopExiting(Br->getSuccessor(0)) ||
-              L->isLoopExiting(Br->getSuccessor(1)))
+          BasicBlock *Succ0 = Br->getSuccessor(0);
+          BasicBlock *Succ1 = Br->getSuccessor(1);
+          if ((L->contains(Succ0) && L->isLoopExiting(Succ0)) ||
+              (L->contains(Succ1) && L->isLoopExiting(Succ1)))
             continue;
           if (dependsOnLocalPhi(L, Br->getCondition())) {
             UP.Threshold += UnrollThresholdIf;