[llvm] r319651 - AMDGPU: fix missing s_waitcnt

Tim Corringham via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 4 04:30:49 PST 2017


Author: timcorringham
Date: Mon Dec  4 04:30:49 2017
New Revision: 319651

URL: http://llvm.org/viewvc/llvm-project?rev=319651&view=rev
Log:
AMDGPU: fix missing s_waitcnt

Summary:
The pass that inserts s_waitcnt instructions where needed propagated
info used to track dependencies for each block by iterating over the
predecessor blocks. The iteration was terminated when a predecessor
that had not yet been processed was encountered. Any info in blocks
later in the list was therefore not processed, leading to the
possiblility of a required s_waitcnt not being inserted.

The fix is simply to change the "break" to "continue" for the
relevant loops, so that all visited blocks are processed. This
is likely what was intended when the code was written.

There is no test case provided for this fix because:
1) the only example that reproduces this is large and resistant to
being reduced
2) the change is trivial

Subscribers: arsenm, kzhuravl, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye

Differential Revision: https://reviews.llvm.org/D40544

Modified:
    llvm/trunk/lib/Target/AMDGPU/SIInsertWaitcnts.cpp

Modified: llvm/trunk/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIInsertWaitcnts.cpp?rev=319651&r1=319650&r2=319651&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIInsertWaitcnts.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIInsertWaitcnts.cpp Mon Dec  4 04:30:49 2017
@@ -1269,7 +1269,7 @@ void SIInsertWaitcnts::mergeInputScoreBr
         BlockWaitcntBracketsMap[pred].get();
     bool Visited = BlockVisitedSet.find(pred) != BlockVisitedSet.end();
     if (!Visited || PredScoreBrackets->getWaitAtBeginning()) {
-      break;
+      continue;
     }
     for (enum InstCounterType T = VM_CNT; T < NUM_INST_CNTS;
          T = (enum InstCounterType)(T + 1)) {
@@ -1308,7 +1308,7 @@ void SIInsertWaitcnts::mergeInputScoreBr
         BlockWaitcntBracketsMap[Pred].get();
     bool Visited = BlockVisitedSet.find(Pred) != BlockVisitedSet.end();
     if (!Visited || PredScoreBrackets->getWaitAtBeginning()) {
-      break;
+      continue;
     }
 
     int GDSSpan = PredScoreBrackets->getEventUB(GDS_GPR_LOCK) -
@@ -1355,7 +1355,7 @@ void SIInsertWaitcnts::mergeInputScoreBr
   // Set the register scoreboard.
   for (MachineBasicBlock *Pred : Block.predecessors()) {
     if (BlockVisitedSet.find(Pred) == BlockVisitedSet.end()) {
-      break;
+      continue;
     }
 
     BlockWaitcntBrackets *PredScoreBrackets =
@@ -1469,7 +1469,7 @@ void SIInsertWaitcnts::mergeInputScoreBr
   // the delayed nature of these operations.
   for (MachineBasicBlock *Pred : Block.predecessors()) {
     if (BlockVisitedSet.find(Pred) == BlockVisitedSet.end()) {
-      break;
+      continue;
     }
 
     BlockWaitcntBrackets *PredScoreBrackets =




More information about the llvm-commits mailing list