Index: lib/Target/AMDGPU/SIInsertWaitcnts.cpp =================================================================== --- lib/Target/AMDGPU/SIInsertWaitcnts.cpp +++ lib/Target/AMDGPU/SIInsertWaitcnts.cpp @@ -285,9 +285,6 @@ const SIRegisterInfo *TRI, const MachineRegisterInfo *MRI, unsigned OpNo, int32_t Val); - void setWaitAtBeginning() { WaitAtBeginning = true; } - void clearWaitAtBeginning() { WaitAtBeginning = false; } - bool getWaitAtBeginning() const { return WaitAtBeginning; } int32_t getMaxVGPR() const { return VgprUB; } int32_t getMaxSGPR() const { return SgprUB; } @@ -335,7 +332,6 @@ private: const GCNSubtarget *ST = nullptr; - bool WaitAtBeginning = false; bool RevisitLoop = false; int32_t PostOrder = 0; int32_t ScoreLBs[NUM_INST_CNTS] = {0}; @@ -859,18 +855,9 @@ AMDGPU::Waitcnt Wait; - // See if an s_waitcnt is forced at block entry, or is needed at - // program end. - if (ScoreBrackets->getWaitAtBeginning()) { - // Note that we have already cleared the state, so we don't need to update - // it. - ScoreBrackets->clearWaitAtBeginning(); - Wait = AMDGPU::Waitcnt::allZero(); - } - // See if this instruction has a forced S_WAITCNT VM. // TODO: Handle other cases of NeedsWaitcntVmBefore() - else if (MI.getOpcode() == AMDGPU::BUFFER_WBINVL1 || + if (MI.getOpcode() == AMDGPU::BUFFER_WBINVL1 || MI.getOpcode() == AMDGPU::BUFFER_WBINVL1_SC || MI.getOpcode() == AMDGPU::BUFFER_WBINVL1_VOL) { Wait.VmCnt = 0; @@ -1264,9 +1251,8 @@ BlockWaitcntBrackets *PredScoreBrackets = BlockWaitcntBracketsMap[Pred].get(); bool Visited = BlockVisitedSet.count(Pred); - if (!Visited || PredScoreBrackets->getWaitAtBeginning()) { + if (!Visited) continue; - } for (auto T : inst_counter_types()) { int span = PredScoreBrackets->getScoreUB(T) - PredScoreBrackets->getScoreLB(T); @@ -1277,17 +1263,6 @@ } } -#if 0 - // LC does not (unlike) add a waitcnt at beginning. Leaving it as marker. - // TODO: how does LC distinguish between function entry and main entry? - // If this is the entry to a function, force a wait. - MachineBasicBlock &Entry = Block.getParent()->front(); - if (Entry.getNumber() == Block.getNumber()) { - ScoreBrackets->setWaitAtBeginning(); - return; - } -#endif - // Now set the current Block's brackets to the largest ending bracket. for (auto T : inst_counter_types()) { ScoreBrackets->setScoreUB(T, MaxPending[T]);