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:
6 ; CHECK: ldrex [[LOADED:r[0-9]+]], [r0]
7 ; CHECK: cmp [[LOADED]], r1
8 ; CHECK: bne [[FAILED:LBB[0-9]+_[0-9]+]]
12 ; CHECK: [[LOOP:LBB[0-9]+_[0-9]+]]:
13 ; CHECK: strex [[STATUS:r[0-9]+]], {{r[0-9]+}}, [r0]
14 ; CHECK: cbz [[STATUS]], [[SUCCESS:LBB[0-9]+_[0-9]+]]
16 ; CHECK: ldrex [[LOADED]], [r0]
17 ; CHECK: cmp [[LOADED]], r1
21 ; CHECK-NOT: cmp {{r[0-9]+}}, {{r[0-9]+}}
28 ; CHECK-NOT: cmp {{r[0-9]+}}, {{r[0-9]+}}
33 %pair = cmpxchg i32* %p, i32 %oldval, i32 %newval seq_cst seq_cst
34 %success = extractvalue { i32, i1 } %pair, 1
35 %conv = zext i1 %success to i32
39 define i1 @test_return_bool(i8* %value, i8 %oldValue, i8 %newValue) {
40 ; CHECK-LABEL: test_return_bool:
42 ; CHECK: uxtb [[OLDBYTE:r[0-9]+]], r1
44 ; CHECK: ldrexb [[LOADED:r[0-9]+]], [r0]
45 ; CHECK: cmp [[LOADED]], [[OLDBYTE]]
46 ; CHECK: bne [[FAIL:LBB[0-9]+_[0-9]+]]
50 ; CHECK: [[LOOP:LBB[0-9]+_[0-9]+]]:
51 ; CHECK: strexb [[STATUS:r[0-9]+]], {{r[0-9]+}}, [r0]
52 ; CHECK: cbz [[STATUS]], [[SUCCESS:LBB[0-9]+_[0-9]+]]
54 ; CHECK: ldrexb [[LOADED]], [r0]
55 ; CHECK: cmp [[LOADED]], [[OLDBYTE]]
59 ; FIXME: this eor is redundant. Need to teach DAG combine that.
62 ; CHECK: movs [[TMP:r[0-9]+]], #0
63 ; CHECK: eor r0, [[TMP]], #1
67 ; CHECK-NOT: cmp {{r[0-9]+}}, {{r[0-9]+}}
68 ; CHECK: movs [[TMP:r[0-9]+]], #1
69 ; CHECK: eor r0, [[TMP]], #1
73 %pair = cmpxchg i8* %value, i8 %oldValue, i8 %newValue acq_rel monotonic
74 %success = extractvalue { i8, i1 } %pair, 1
75 %failure = xor i1 %success, 1
79 define void @test_conditional(i32* %p, i32 %oldval, i32 %newval) {
80 ; CHECK-LABEL: test_conditional:
82 ; CHECK: ldrex [[LOADED:r[0-9]+]], [r0]
83 ; CHECK: cmp [[LOADED]], r1
84 ; CHECK: bne [[FAILED:LBB[0-9]+_[0-9]+]]
88 ; CHECK: [[LOOP:LBB[0-9]+_[0-9]+]]:
89 ; CHECK: strex [[STATUS:r[0-9]+]], r2, [r0]
90 ; CHECK: cbz [[STATUS]], [[SUCCESS:LBB[0-9]+_[0-9]+]]
92 ; CHECK: ldrex [[LOADED]], [r0]
93 ; CHECK: cmp [[LOADED]], r1
97 ; CHECK-NOT: cmp {{r[0-9]+}}, {{r[0-9]+}}
102 ; CHECK: [[SUCCESS]]:
103 ; CHECK-NOT: cmp {{r[0-9]+}}, {{r[0-9]+}}
107 %pair = cmpxchg i32* %p, i32 %oldval, i32 %newval seq_cst seq_cst
108 %success = extractvalue { i32, i1 } %pair, 1
109 br i1 %success, label %true, label %false
112 tail call void @bar() #2
116 tail call void @baz() #2