2014-06-14 00:45:52 +08:00
|
|
|
; RUN: llc < %s -mtriple=armv7-apple-ios -verify-machineinstrs | FileCheck %s
|
|
|
|
|
|
|
|
define void @test_cmpxchg_weak(i32 *%addr, i32 %desired, i32 %new) {
|
|
|
|
; CHECK-LABEL: test_cmpxchg_weak:
|
|
|
|
|
|
|
|
%pair = cmpxchg weak i32* %addr, i32 %desired, i32 %new seq_cst monotonic
|
|
|
|
%oldval = extractvalue { i32, i1 } %pair, 0
|
2015-09-23 01:22:58 +08:00
|
|
|
; CHECK-NEXT: BB#0:
|
|
|
|
; CHECK-NEXT: ldrex [[LOADED:r[0-9]+]], [r0]
|
|
|
|
; CHECK-NEXT: cmp [[LOADED]], r1
|
|
|
|
; CHECK-NEXT: bne [[LDFAILBB:LBB[0-9]+_[0-9]+]]
|
|
|
|
; CHECK-NEXT: BB#1:
|
2016-02-23 04:55:50 +08:00
|
|
|
; CHECK-NEXT: dmb ish
|
2015-09-23 01:22:58 +08:00
|
|
|
; CHECK-NEXT: strex [[SUCCESS:r[0-9]+]], r2, [r0]
|
|
|
|
; CHECK-NEXT: cmp [[SUCCESS]], #0
|
2017-02-01 07:48:32 +08:00
|
|
|
; CHECK-NEXT: beq [[SUCCESSBB:LBB[0-9]+_[0-9]+]]
|
2015-09-23 01:22:58 +08:00
|
|
|
; CHECK-NEXT: BB#2:
|
|
|
|
; CHECK-NEXT: str r3, [r0]
|
|
|
|
; CHECK-NEXT: bx lr
|
|
|
|
; CHECK-NEXT: [[LDFAILBB]]:
|
|
|
|
; CHECK-NEXT: clrex
|
2017-02-01 07:48:32 +08:00
|
|
|
; CHECK-NEXT: str r3, [r0]
|
|
|
|
; CHECK-NEXT: bx lr
|
|
|
|
; CHECK-NEXT: [[SUCCESSBB]]:
|
|
|
|
; CHECK-NEXT: dmb ish
|
2015-09-23 01:22:58 +08:00
|
|
|
; CHECK-NEXT: str r3, [r0]
|
|
|
|
; CHECK-NEXT: bx lr
|
2014-06-14 00:45:52 +08:00
|
|
|
|
|
|
|
store i32 %oldval, i32* %addr
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
define i1 @test_cmpxchg_weak_to_bool(i32, i32 *%addr, i32 %desired, i32 %new) {
|
|
|
|
; CHECK-LABEL: test_cmpxchg_weak_to_bool:
|
|
|
|
|
|
|
|
%pair = cmpxchg weak i32* %addr, i32 %desired, i32 %new seq_cst monotonic
|
|
|
|
%success = extractvalue { i32, i1 } %pair, 1
|
|
|
|
|
2015-09-23 01:22:58 +08:00
|
|
|
; CHECK-NEXT: BB#0:
|
|
|
|
; CHECK-NEXT: ldrex [[LOADED:r[0-9]+]], [r1]
|
|
|
|
; CHECK-NEXT: cmp [[LOADED]], r2
|
|
|
|
; CHECK-NEXT: bne [[LDFAILBB:LBB[0-9]+_[0-9]+]]
|
|
|
|
; CHECK-NEXT: BB#1:
|
2016-02-23 04:55:50 +08:00
|
|
|
; CHECK-NEXT: dmb ish
|
2015-09-23 01:22:58 +08:00
|
|
|
; CHECK-NEXT: mov r0, #0
|
2016-02-23 04:55:50 +08:00
|
|
|
; CHECK-NEXT: strex [[SUCCESS:r[0-9]+]], r3, [r1]
|
2015-09-23 01:22:58 +08:00
|
|
|
; CHECK-NEXT: cmp [[SUCCESS]], #0
|
|
|
|
; CHECK-NEXT: bxne lr
|
|
|
|
; CHECK-NEXT: dmb ish
|
|
|
|
; CHECK-NEXT: mov r0, #1
|
|
|
|
; CHECK-NEXT: bx lr
|
|
|
|
; CHECK-NEXT: [[LDFAILBB]]:
|
|
|
|
; CHECK-NEXT: clrex
|
|
|
|
; CHECK-NEXT: mov r0, #0
|
|
|
|
; CHECK-NEXT: bx lr
|
2014-06-14 00:45:52 +08:00
|
|
|
|
|
|
|
ret i1 %success
|
|
|
|
}
|