[llvm] [NVPTX] Add syncscope support for cmpxchg (PR #140812)

Alex MacLean via llvm-commits llvm-commits at lists.llvm.org
Fri May 30 14:53:38 PDT 2025


================
@@ -6317,10 +6317,12 @@ Instruction *NVPTXTargetLowering::emitLeadingFence(IRBuilderBase &Builder,
 
   // Specialize for cmpxchg
   // Emit a fence.sc leading fence for cmpxchg seq_cst which are not emulated
+  SyncScope::ID SSID = cast<AtomicCmpXchgInst>(Inst)->getSyncScopeID();
   if (isReleaseOrStronger(Ord))
     return Ord == AtomicOrdering::SequentiallyConsistent
-               ? Builder.CreateFence(AtomicOrdering::SequentiallyConsistent)
-               : Builder.CreateFence(AtomicOrdering::Release);
+               ? Builder.CreateFence(AtomicOrdering::SequentiallyConsistent,
----------------
AlexMaclean wrote:

Nit: can you push the ternary operator inward so it is the first operand to CreateFence?

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


More information about the llvm-commits mailing list