mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-25 04:35:32 -04:00
16a661561f
ARM counterpart to r248291: 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@248294 91177308-0d34-0410-b5e6-96231b3b80d8
69 lines
2.6 KiB
LLVM
69 lines
2.6 KiB
LLVM
; RUN: llc < %s -mtriple=arm-linux-gnueabi -asm-verbose=false -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-ARM
|
|
; RUN: llc < %s -mtriple=thumb-linux-gnueabi -asm-verbose=false -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-THUMB
|
|
|
|
; RUN: llc < %s -mtriple=armv7-linux-gnueabi -asm-verbose=false -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-ARMV7
|
|
; RUN: llc < %s -mtriple=thumbv7-linux-gnueabi -asm-verbose=false -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-THUMBV7
|
|
|
|
define zeroext i1 @test_cmpxchg_res_i8(i8* %addr, i8 %desired, i8 zeroext %new) {
|
|
entry:
|
|
%0 = cmpxchg i8* %addr, i8 %desired, i8 %new monotonic monotonic
|
|
%1 = extractvalue { i8, i1 } %0, 1
|
|
ret i1 %1
|
|
}
|
|
|
|
; CHECK-ARM-LABEL: test_cmpxchg_res_i8
|
|
; CHECK-ARM: bl __sync_val_compare_and_swap_1
|
|
; CHECK-ARM: mov [[REG:r[0-9]+]], #0
|
|
; CHECK-ARM: cmp r0, {{r[0-9]+}}
|
|
; CHECK-ARM: moveq [[REG]], #1
|
|
; CHECK-ARM: mov r0, [[REG]]
|
|
|
|
; CHECK-THUMB-LABEL: test_cmpxchg_res_i8
|
|
; CHECK-THUMB: bl __sync_val_compare_and_swap_1
|
|
; CHECK-THUMB-NOT: mov [[R1:r[0-7]]], r0
|
|
; CHECK-THUMB: push {r0}
|
|
; CHECK-THUMB: pop {[[R1:r[0-7]]]}
|
|
; CHECK-THUMB: movs r0, #1
|
|
; CHECK-THUMB: movs [[R2:r[0-9]+]], #0
|
|
; CHECK-THUMB: cmp [[R1]], {{r[0-9]+}}
|
|
; CHECK-THU<B: beq
|
|
; CHECK-THUMB: push {[[R2]]}
|
|
; CHECK-THUMB: pop {r0}
|
|
|
|
; CHECK-ARMV7-LABEL: test_cmpxchg_res_i8:
|
|
; CHECK-ARMV7-NEXT: .fnstart
|
|
; CHECK-ARMV7-NEXT: uxtb [[DESIRED:r[0-9]+]], r1
|
|
; CHECK-ARMV7-NEXT: [[TRY:.LBB[0-9_]+]]:
|
|
; CHECK-ARMV7-NEXT: ldrexb [[LD:r[0-9]+]], [r0]
|
|
; CHECK-ARMV7-NEXT: cmp [[LD]], [[DESIRED]]
|
|
; CHECK-ARMV7-NEXT: bne [[FAIL:.LBB[0-9_]+]]
|
|
; CHECK-ARMV7-NEXT: strexb [[SUCCESS:r[0-9]+]], r2, [r0]
|
|
; CHECK-ARMV7-NEXT: mov [[RES:r[0-9]+]], #1
|
|
; CHECK-ARMV7-NEXT: cmp [[SUCCESS]], #0
|
|
; CHECK-ARMV7-NEXT: bne [[TRY]]
|
|
; CHECK-ARMV7-NEXT: b [[END:.LBB[0-9_]+]]
|
|
; CHECK-ARMV7-NEXT: [[FAIL]]:
|
|
; CHECK-ARMV7-NEXT: clrex
|
|
; CHECK-ARMV7-NEXT: mov [[RES]], #0
|
|
; CHECK-ARMV7-NEXT: [[END]]:
|
|
; CHECK-ARMV7-NEXT: mov r0, [[RES]]
|
|
; CHECK-ARMV7-NEXT: bx lr
|
|
|
|
; CHECK-THUMBV7-LABEL: test_cmpxchg_res_i8:
|
|
; CHECK-THUMBV7-NEXT: .fnstart
|
|
; CHECK-THUMBV7-NEXT: uxtb [[DESIRED:r[0-9]+]], r1
|
|
; CHECK-THUMBV7-NEXT: b [[TRYLD:.LBB[0-9_]+]]
|
|
; CHECK-THUMBV7-NEXT: [[TRYST:.LBB[0-9_]+]]:
|
|
; CHECK-THUMBV7-NEXT: strexb [[SUCCESS:r[0-9]+]], r2, [r0]
|
|
; CHECK-THUMBV7-NEXT: cmp [[SUCCESS]], #0
|
|
; CHECK-THUMBV7-NEXT: itt eq
|
|
; CHECK-THUMBV7-NEXT: moveq r0, #1
|
|
; CHECK-THUMBV7-NEXT: bxeq lr
|
|
; CHECK-THUMBV7-NEXT: [[TRYLD]]:
|
|
; CHECK-THUMBV7-NEXT: ldrexb [[LD:r[0-9]+]], [r0]
|
|
; CHECK-THUMBV7-NEXT: cmp [[LD]], [[DESIRED]]
|
|
; CHECK-THUMBV7-NEXT: beq [[TRYST:.LBB[0-9_]+]]
|
|
; CHECK-THUMBV7-NEXT: clrex
|
|
; CHECK-THUMBV7-NEXT: movs r0, #0
|
|
; CHECK-THUMBV7-NEXT: bx lr
|