[llvm] [AtomicExpand] Implement SUB → ADD(-x) and FSUB → FADD(-x) (PR #221425)

Akshay Deodhar via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 17:54:23 PDT 2026


================
@@ -7790,22 +7794,27 @@ NVPTXTargetLowering::shouldExpandAtomicRMWInIR(const AtomicRMWInst *AI) const {
   case AtomicRMWInst::BinOp::Max:
   case AtomicRMWInst::BinOp::Min:
   case AtomicRMWInst::BinOp::UMax:
-  case AtomicRMWInst::BinOp::UMin:
+  case AtomicRMWInst::BinOp::UMin: {
+    AtomicExpansionKind ExpansionKind =
+        AI->getOperation() == AtomicRMWInst::BinOp::Sub
+            ? AtomicExpansionKind::Expand
+            : AtomicExpansionKind::None;
     switch (BitWidth) {
     case 8:
     case 16:
       return AtomicExpansionKind::CmpXChg;
     case 32:
-      return AtomicExpansionKind::None;
+      return ExpansionKind;
     case 64:
       if (STI.hasAtomMinMax64())
----------------
akshayrdeodhar wrote:

So minmax/xor are introduced in a later SM version, and add is always available. Once you rebase on that fix, add will always be considered to be available, and will not be guarded by this check. Is that the right understanding?

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


More information about the llvm-commits mailing list