[AArch64] Emit clrex in the expanded cmpxchg fail block.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Tue, 22 Sep 2015 17:21:44 +0000 (17:21 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Tue, 22 Sep 2015 17:21:44 +0000 (17:21 +0000)
commitee629d83953a0a66d95ae3ed1cc88f2cb0e0d163
tree5c39973e2acd41851ce833cfd938bc24f119283d
parentc8a4540af107bbab49a0861ffa07ed9e6f13bb3a
[AArch64] Emit clrex in the expanded cmpxchg fail block.

In the comparison failure block of a cmpxchg expansion, the initial
ldrex/ldxr will not be followed by a matching strex/stxr.
On ARM/AArch64, this unnecessarily ties up the execution monitor,
which might have a negative performance impact on some uarchs.

Instead, release the monitor in the failure block.
The clrex instruction was designed for this: use it.

Also see ARMARM v8-A B2.10.2:
"Exclusive access instructions and Shareable memory locations".

Differential Revision: http://reviews.llvm.org/D13033

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248291 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Target/TargetLowering.h
lib/CodeGen/AtomicExpandPass.cpp
lib/Target/AArch64/AArch64ISelLowering.cpp
lib/Target/AArch64/AArch64ISelLowering.h
test/CodeGen/AArch64/arm64-atomic.ll
test/CodeGen/AArch64/atomic-ops.ll