[llvm-dev] RFC: Atomic LL/SC loops in LLVM revisited

Alex Bradbury via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 14 02:01:00 PDT 2018

On 13 June 2018 at 23:37, James Y Knight via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> So, now I wonder -- is there actually a measurable performance impact (on,
> say, ARM) if we were to just always emit the "strong" cmpxchg loop? I'm
> feeling rather inclined to say we should not implement the weak variant at
> all. (And, if others agree with my diagnosis here, also propose to deprecate
> it from the C/C++ languages...)

I'm not sure deprecation is justified. A "Sufficiently Smart Compiler"
could make use of the knowledge that a weak cmpxchg was considered
sufficient by the programmer, and use the weak cmpxchg form if the
surrounding loop can be shown to meet the forward progress guarantees
of the architecture. In LLVM, this could be done by analyzing the
surrounding basic block when expanding the cmpxchg pseudo after
regalloc. It's unlikely it would be worth the hassle, but it does seem
a viable approach.



More information about the llvm-dev mailing list