1 ; RUN: llc -mtriple=aarch64-apple-ios7.0 -o - %s | FileCheck %s 2 3 define i32 @test_return(i32* %p, i32 %oldval, i32 %newval) { 4 ; CHECK-LABEL: test_return: 5 6 ; CHECK: [[LOOP:LBB[0-9]+_[0-9]+]]: 7 ; CHECK: ldaxr [[LOADED:w[0-9]+]], [x0] 8 ; CHECK: cmp [[LOADED]], w1 9 ; CHECK: b.ne [[FAILED:LBB[0-9]+_[0-9]+]] 10 11 ; CHECK: stlxr [[STATUS:w[0-9]+]], {{w[0-9]+}}, [x0] 12 ; CHECK: cbnz [[STATUS]], [[LOOP]] 13 14 ; CHECK-NOT: cmp {{w[0-9]+}}, {{w[0-9]+}} 15 ; CHECK: orr w0, wzr, #0x1 16 ; CHECK: ret 17 18 ; CHECK: [[FAILED]]: 19 ; CHECK-NOT: cmp {{w[0-9]+}}, {{w[0-9]+}} 20 ; CHECK: mov w0, wzr 21 ; CHECK: ret 22 23 %pair = cmpxchg i32* %p, i32 %oldval, i32 %newval seq_cst seq_cst 24 %success = extractvalue { i32, i1 } %pair, 1 25 %conv = zext i1 %success to i32 26 ret i32 %conv 27 } 28 29 define i1 @test_return_bool(i8* %value, i8 %oldValue, i8 %newValue) { 30 ; CHECK-LABEL: test_return_bool: 31 32 ; CHECK: [[LOOP:LBB[0-9]+_[0-9]+]]: 33 ; CHECK: ldaxrb [[LOADED:w[0-9]+]], [x0] 34 ; CHECK: cmp [[LOADED]], w1, uxtb 35 ; CHECK: b.ne [[FAILED:LBB[0-9]+_[0-9]+]] 36 37 ; CHECK: stlxrb [[STATUS:w[0-9]+]], {{w[0-9]+}}, [x0] 38 ; CHECK: cbnz [[STATUS]], [[LOOP]] 39 40 ; CHECK-NOT: cmp {{w[0-9]+}}, {{w[0-9]+}} 41 ; FIXME: DAG combine should be able to deal with this. 42 ; CHECK: orr [[TMP:w[0-9]+]], wzr, #0x1 43 ; CHECK: eor w0, [[TMP]], #0x1 44 ; CHECK: ret 45 46 ; CHECK: [[FAILED]]: 47 ; CHECK-NOT: cmp {{w[0-9]+}}, {{w[0-9]+}} 48 ; CHECK: mov [[TMP:w[0-9]+]], wzr 49 ; CHECK: eor w0, [[TMP]], #0x1 50 ; CHECK: ret 51 52 %pair = cmpxchg i8* %value, i8 %oldValue, i8 %newValue acq_rel monotonic 53 %success = extractvalue { i8, i1 } %pair, 1 54 %failure = xor i1 %success, 1 55 ret i1 %failure 56 } 57 58 define void @test_conditional(i32* %p, i32 %oldval, i32 %newval) { 59 ; CHECK-LABEL: test_conditional: 60 61 ; CHECK: [[LOOP:LBB[0-9]+_[0-9]+]]: 62 ; CHECK: ldaxr [[LOADED:w[0-9]+]], [x0] 63 ; CHECK: cmp [[LOADED]], w1 64 ; CHECK: b.ne [[FAILED:LBB[0-9]+_[0-9]+]] 65 66 ; CHECK: stlxr [[STATUS:w[0-9]+]], w2, [x0] 67 ; CHECK: cbnz [[STATUS]], [[LOOP]] 68 69 ; CHECK-NOT: cmp {{w[0-9]+}}, {{w[0-9]+}} 70 ; CHECK: b _bar 71 72 ; CHECK: [[FAILED]]: 73 ; CHECK-NOT: cmp {{w[0-9]+}}, {{w[0-9]+}} 74 ; CHECK: b _baz 75 76 %pair = cmpxchg i32* %p, i32 %oldval, i32 %newval seq_cst seq_cst 77 %success = extractvalue { i32, i1 } %pair, 1 78 br i1 %success, label %true, label %false 79 80 true: 81 tail call void @bar() #2 82 br label %end 83 84 false: 85 tail call void @baz() #2 86 br label %end 87 88 end: 89 ret void 90 } 91 92 declare void @bar() 93 declare void @baz() 94