1 ; RUN: llc -mtriple=thumbv7s-apple-ios7.0 -o - %s | FileCheck %s
3 define i32 @test_return(i32* %p, i32 %oldval, i32 %newval) {
4 ; CHECK-LABEL: test_return:
8 ; CHECK: [[LOOP:LBB[0-9]+_[0-9]+]]:
9 ; CHECK: ldrex [[LOADED:r[0-9]+]], [r0]
10 ; CHECK: cmp [[LOADED]], r1
11 ; CHECK: bne [[FAILED:LBB[0-9]+_[0-9]+]]
13 ; CHECK: strex [[STATUS:r[0-9]+]], {{r[0-9]+}}, [r0]
14 ; CHECK: cmp [[STATUS]], #0
17 ; CHECK-NOT: cmp {{r[0-9]+}}, {{r[0-9]+}}
23 ; CHECK-NOT: cmp {{r[0-9]+}}, {{r[0-9]+}}
28 %pair = cmpxchg i32* %p, i32 %oldval, i32 %newval seq_cst seq_cst
29 %success = extractvalue { i32, i1 } %pair, 1
30 %conv = zext i1 %success to i32
34 define i1 @test_return_bool(i8* %value, i8 %oldValue, i8 %newValue) {
35 ; CHECK-LABEL: test_return_bool:
38 ; CHECK: uxtb [[OLDBYTE:r[0-9]+]], r1
40 ; CHECK: [[LOOP:LBB[0-9]+_[0-9]+]]:
41 ; CHECK: ldrexb [[LOADED:r[0-9]+]], [r0]
42 ; CHECK: cmp [[LOADED]], [[OLDBYTE]]
43 ; CHECK: bne [[FAIL:LBB[0-9]+_[0-9]+]]
45 ; CHECK: strexb [[STATUS:r[0-9]+]], {{r[0-9]+}}, [r0]
46 ; CHECK: cmp [[STATUS]], #0
49 ; FIXME: this eor is redundant. Need to teach DAG combine that.
50 ; CHECK-NOT: cmp {{r[0-9]+}}, {{r[0-9]+}}
51 ; CHECK: movs [[TMP:r[0-9]+]], #1
52 ; CHECK: eor r0, [[TMP]], #1
56 ; CHECK: movs [[TMP:r[0-9]+]], #0
57 ; CHECK: eor r0, [[TMP]], #1
61 %pair = cmpxchg i8* %value, i8 %oldValue, i8 %newValue acq_rel monotonic
62 %success = extractvalue { i8, i1 } %pair, 1
63 %failure = xor i1 %success, 1
67 define void @test_conditional(i32* %p, i32 %oldval, i32 %newval) {
68 ; CHECK-LABEL: test_conditional:
72 ; CHECK: [[LOOP:LBB[0-9]+_[0-9]+]]:
73 ; CHECK: ldrex [[LOADED:r[0-9]+]], [r0]
74 ; CHECK: cmp [[LOADED]], r1
75 ; CHECK: bne [[FAILED:LBB[0-9]+_[0-9]+]]
77 ; CHECK: strex [[STATUS:r[0-9]+]], r2, [r0]
78 ; CHECK: cmp [[STATUS]], #0
81 ; CHECK-NOT: cmp {{r[0-9]+}}, {{r[0-9]+}}
86 ; CHECK-NOT: cmp {{r[0-9]+}}, {{r[0-9]+}}
90 %pair = cmpxchg i32* %p, i32 %oldval, i32 %newval seq_cst seq_cst
91 %success = extractvalue { i32, i1 } %pair, 1
92 br i1 %success, label %true, label %false
95 tail call void @bar() #2
99 tail call void @baz() #2