[llvm] [AMDGPU] s_monitor_sleep shall not use sleep_forever on gfx1250 (PR #220366)

Krzysztof Drewniak via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 1 14:47:34 PDT 2026


================
@@ -209,6 +214,24 @@ bool AMDGPULowerIntrinsicsImpl::visitPtrSBufferLoad(IntrinsicInst &I) {
   return true;
 }
 
+bool AMDGPULowerIntrinsicsImpl::visitMonitorSleep(IntrinsicInst &I) {
+  assert(I.getIntrinsicID() == Intrinsic::amdgcn_s_monitor_sleep);
+
+  const GCNSubtarget &ST = TM.getSubtarget<GCNSubtarget>(*I.getFunction());
+  if (!ST.hasNoSleepForever())
+    return false;
+
+  int Sleep = cast<ConstantInt>(I.getArgOperand(0))->getSExtValue();
+  if (!(Sleep & 0x8000))
+    return false;
+
+  IRBuilder<> B(&I);
+  Value *NewSleep = B.getInt16(0x2000); // Maximum
+  I.setArgOperand(0, NewSleep);
+
+  return true;
----------------
krzysz00 wrote:

Is silently fixing this the right approach here?

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


More information about the llvm-commits mailing list