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

via llvm-commits llvm-commits at lists.llvm.org
Fri May 30 09:33:37 PDT 2025


================
@@ -325,13 +327,18 @@ bool AtomicExpandImpl::processAtomicInstr(Instruction *I) {
       // expandAtomicCmpXchg in that case.
       FenceOrdering = CASI->getMergedOrdering();
       auto CASOrdering = TLI->atomicOperationOrderAfterFenceSplit(CASI);
+      SSID = CASI->getSyncScopeID();
 
       CASI->setSuccessOrdering(CASOrdering);
       CASI->setFailureOrdering(CASOrdering);
+      // If CAS ordering is monotonic, then the operation will
+      // take default scope. Otherwise, it will retain its scope
----------------
gonzalobg wrote:

Thank you for calling this out.
The comment explains what the code does, but it does not explain "why" it does it, and from looking around its not obvious to me why it is correct for CAS monotonic to take the default scope.

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


More information about the llvm-commits mailing list