[llvm] [AMDGPU] Avoid setting GLC for image atomics when result is unused (PR #150742)

Harrison Hao via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 27 20:21:57 PDT 2025


================
@@ -8780,8 +8780,10 @@ SDValue SITargetLowering::lowerImage(SDValue Op,
   }
 
   unsigned CPol = Op.getConstantOperandVal(ArgOffset + Intr->CachePolicyIndex);
-  if (BaseOpcode->Atomic)
-    CPol |= AMDGPU::CPol::GLC; // TODO no-return optimization
+  // Keep GLC only when the atomic's result is actually used.
+  if (BaseOpcode->Atomic && !Op.getValue(0).use_empty())
+    CPol |= AMDGPU::CPol::GLC;
+
----------------
harrisonGPU wrote:

Thanks, I will try to investigate. :-)

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


More information about the llvm-commits mailing list