[llvm] [IR][AtomicExpand] Add elementwise modifier to atomicrmw; automatically expand for all targets (PR #189517)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 1 03:13:19 PDT 2026


================
@@ -342,11 +362,28 @@ bool AtomicExpandImpl::processAtomicInstr(Instruction *I) {
 
   if (auto *RMWI = dyn_cast<AtomicRMWInst>(I)) {
     if (!atomicSizeSupported(TLI, RMWI)) {
+      if (RMWI->isElementwise())
+        return expandElementwiseAtomicRMW(RMWI);
       expandAtomicRMWToLibcall(RMWI);
       return true;
     }
 
     bool MadeChange = false;
+
+    if (RMWI->isElementwise()) {
+      if (!TLI->shouldExpandAtomicRMWElementwiseInIR(RMWI))
+        return false;
+      if (canReuseWholeValueAtomicRMW(RMWI)) {
----------------
arsenm wrote:

Invert and early return 

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


More information about the llvm-commits mailing list