[all-commits] [llvm/llvm-project] 85a9f2: [PowerPC] enable AtomicExpandImpl::expandAtomicCmp...

zhijian lin via All-commits all-commits at lists.llvm.org
Fri Jun 13 06:15:19 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 85a9f2e14859b472750f13fb441291e6e9c893a0
      https://github.com/llvm/llvm-project/commit/85a9f2e14859b472750f13fb441291e6e9c893a0
  Author: zhijian lin <zhijian at ca.ibm.com>
  Date:   2025-06-13 (Fri, 13 Jun 2025)

  Changed paths:
    M llvm/include/llvm/CodeGen/TargetLowering.h
    M llvm/include/llvm/IR/IntrinsicsPowerPC.td
    M llvm/lib/Target/PowerPC/PPCISelLowering.cpp
    M llvm/lib/Target/PowerPC/PPCISelLowering.h
    M llvm/lib/Target/PowerPC/PPCInstr64Bit.td
    M llvm/lib/Target/PowerPC/PPCInstrInfo.td
    M llvm/test/CodeGen/PowerPC/PR35812-neg-cmpxchg.ll
    M llvm/test/CodeGen/PowerPC/all-atomics.ll
    M llvm/test/CodeGen/PowerPC/atomic-2.ll
    M llvm/test/CodeGen/PowerPC/atomic-compare-exchange-weak.ll
    M llvm/test/CodeGen/PowerPC/atomic-float.ll
    M llvm/test/CodeGen/PowerPC/atomicrmw-cond-sub-clamp.ll
    M llvm/test/CodeGen/PowerPC/atomicrmw-uinc-udec-wrap.ll
    M llvm/test/CodeGen/PowerPC/atomics-regression.ll
    M llvm/test/CodeGen/PowerPC/atomics.ll
    M llvm/test/CodeGen/PowerPC/loop-comment.ll
    M llvm/test/Transforms/AtomicExpand/PowerPC/atomicrmw-fp.ll

  Log Message:
  -----------
  [PowerPC] enable AtomicExpandImpl::expandAtomicCmpXchg for powerpc (#142395)

In PowerPC, the AtomicCmpXchgInst is lowered to
ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS. However, this node does not handle
the weak attribute of AtomicCmpXchgInst. As a result, when compiling C++
atomic_compare_exchange_weak_explicit, the generated assembly includes a
"reservation lost" loop — i.e., it branches back and retries if the
stwcx. (store-conditional) fails. This differs from GCC’s codegen, which
does not include that loop for weak compare-exchange.

Since PowerPC uses LL/SC-style atomic instructions, the patch enables
AtomicExpandImpl::expandAtomicCmpXchg for PowerPC. With this, the weak
attribute is properly respected, and the "reservation lost" loop is
removed for weak operations.

---------

Co-authored-by: Matt Arsenault <arsenm2 at gmail.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list