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

Yonah Goldberg via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 19:00:37 PDT 2026


================
@@ -7877,9 +7886,12 @@ AtomicOrdering NVPTXTargetLowering::atomicOperationOrderAfterFenceSplit(
           STI.getMinCmpXchgSizeInBits())
     return AtomicOrdering::Acquire;
   else if (auto *RI = dyn_cast<AtomicRMWInst>(I);
-           RI && RI->getOrdering() == AtomicOrdering::SequentiallyConsistent &&
-           shouldExpandAtomicRMWInIR(RI) == AtomicExpansionKind::None)
-    return AtomicOrdering::Acquire;
+           RI && RI->getOrdering() == AtomicOrdering::SequentiallyConsistent) {
+    AtomicExpansionKind ExpansionKind = shouldExpandAtomicRMWInIR(RI);
+    if (ExpansionKind == AtomicExpansionKind::None ||
----------------
YonahGoldberg wrote:

I think we can just make the check that the expansion kind is expand AND  the atomic is not elementwise. I agree for elementwise expansions we don't want the atomic operation after fence split to be acquire because we are bracketing the entire elementwise expansion with acquire/release fences that ensure the ordering.

I'm just going to add this on in the elementwise PR so we don't block this.

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


More information about the llvm-commits mailing list