[llvm] [WIP][AMDGPU][SIInsertWaitcnts] Do not add s_waitcnt when the counters are known to be 0 already (PR #65735)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 12 06:05:36 PDT 2023


================
@@ -869,6 +876,26 @@ static bool updateOperandIfDifferent(MachineInstr &MI, uint16_t OpName,
   return true;
 }
 
+bool SIInsertWaitcnts::updateWaitcntIfSoft(MachineInstr *&Waitcnt) const {
+  unsigned Opcode = Waitcnt->getOpcode();
+  if (!SIInstrInfo::isSoftWaitcnt(Opcode))
+    return false;
+
+  MachineBasicBlock &Block = *Waitcnt->getParent();
+  auto InsertBefore = Waitcnt->getIterator();
+  auto DL = Waitcnt->getDebugLoc();
+  auto &MCInfo = TII->get(SIInstrInfo::getNonSoftWaitcntOpcode(Opcode));
----------------
arsenm wrote:

You can just setDesc instead of creating a whole new instruction 

https://github.com/llvm/llvm-project/pull/65735


More information about the llvm-commits mailing list