[llvm] [AMDGPU] Add dynamic threshold for DPP atomic optimizer on integer LDS atomics (PR #186762)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue May 12 06:03:42 PDT 2026


================
@@ -646,7 +659,22 @@ static Value *buildMul(IRBuilder<> &B, Value *LHS, Value *RHS) {
 void AMDGPUAtomicOptimizerImpl::optimizeAtomic(Instruction &I,
                                                AtomicRMWInst::BinOp Op,
                                                unsigned ValIdx,
-                                               bool ValDivergent) const {
+                                               bool ValDivergent,
+                                               bool IsLDS) const {
+  // Check !amdgpu.atomic.lds.dpp metadata for per-atomic DPP control.
+  //   !{!"none"}    – skip DPP optimization entirely for this atomic.
+  //   !{!"dynamic"} – use a dynamic active-lane-count branch.
+  StringRef LDSDPPMode;
+  if (IsLDS && ValDivergent && ScanImpl == ScanOptions::DPP) {
+    if (MDNode *MD = I.getMetadata("amdgpu.atomic.lds.dpp")) {
+      if (MD->getNumOperands() == 1)
+        if (auto *S = dyn_cast<MDString>(MD->getOperand(0)))
+          LDSDPPMode = S->getString();
----------------
arsenm wrote:

The verifier should enforce the structure, it shouldn't 'require validating the structure in parsing 

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


More information about the llvm-commits mailing list