[flang-commits] [flang] [llvm] [mlir] [flang][OpenMP] Support for "atomic compare capture" (PR #202315)

via flang-commits flang-commits at lists.llvm.org
Wed Jul 1 08:51:50 PDT 2026


================
@@ -5527,6 +5525,25 @@ convertOmpAtomicCapture(omp::AtomicCaptureOp atomicCaptureOp,
       return failure();
 
     builder.restoreIP(*afterIP);
+
+    // Postfix: v = select(success, D, old) — captures new value of x.
+    if (isPostfixCapture && !isFailOnly) {
+      llvm::BasicBlock *curBB = builder.GetInsertBlock();
+      llvm::Instruction *cmpxchgInst = nullptr;
+      for (auto &inst : llvm::reverse(*curBB)) {
+        if (isa<llvm::AtomicCmpXchgInst>(&inst)) {
+          cmpxchgInst = &inst;
+          break;
+        }
+      }
+      assert(cmpxchgInst && "expected cmpxchg instruction");
----------------
SunilKuravinakop wrote:

I have addressed this in the latest push. Can you please review the code?

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


More information about the flang-commits mailing list