1; RUN: llc -verify-machineinstrs -mtriple=aarch64-linux-gnu -O0 %s -o - | FileCheck %s 2 3define { i8, i1 } @test_cmpxchg_8(i8* %addr, i8 %desired, i8 %new) nounwind { 4; CHECK-LABEL: test_cmpxchg_8: 5; CHECK: [[RETRY:.LBB[0-9]+_[0-9]+]]: 6; CHECK: ldaxrb [[OLD:w[0-9]+]], [x0] 7; CHECK: cmp [[OLD]], w1, uxtb 8; CHECK: b.ne [[DONE:.LBB[0-9]+_[0-9]+]] 9; CHECK: stlxrb [[STATUS:w[3-9]]], w2, [x0] 10; CHECK: cbnz [[STATUS]], [[RETRY]] 11; CHECK: [[DONE]]: 12; CHECK: subs {{w[0-9]+}}, [[OLD]], w1 13; CHECK: cset {{w[0-9]+}}, eq 14 %res = cmpxchg i8* %addr, i8 %desired, i8 %new seq_cst monotonic 15 ret { i8, i1 } %res 16} 17 18define { i16, i1 } @test_cmpxchg_16(i16* %addr, i16 %desired, i16 %new) nounwind { 19; CHECK-LABEL: test_cmpxchg_16: 20; CHECK: [[RETRY:.LBB[0-9]+_[0-9]+]]: 21; CHECK: ldaxrh [[OLD:w[0-9]+]], [x0] 22; CHECK: cmp [[OLD]], w1, uxth 23; CHECK: b.ne [[DONE:.LBB[0-9]+_[0-9]+]] 24; CHECK: stlxrh [[STATUS:w[3-9]]], w2, [x0] 25; CHECK: cbnz [[STATUS]], [[RETRY]] 26; CHECK: [[DONE]]: 27; CHECK: subs {{w[0-9]+}}, [[OLD]], w1 28; CHECK: cset {{w[0-9]+}}, eq 29 %res = cmpxchg i16* %addr, i16 %desired, i16 %new seq_cst monotonic 30 ret { i16, i1 } %res 31} 32 33define { i32, i1 } @test_cmpxchg_32(i32* %addr, i32 %desired, i32 %new) nounwind { 34; CHECK-LABEL: test_cmpxchg_32: 35; CHECK: [[RETRY:.LBB[0-9]+_[0-9]+]]: 36; CHECK: ldaxr [[OLD:w[0-9]+]], [x0] 37; CHECK: cmp [[OLD]], w1 38; CHECK: b.ne [[DONE:.LBB[0-9]+_[0-9]+]] 39; CHECK: stlxr [[STATUS:w[3-9]]], w2, [x0] 40; CHECK: cbnz [[STATUS]], [[RETRY]] 41; CHECK: [[DONE]]: 42; CHECK: subs {{w[0-9]+}}, [[OLD]], w1 43; CHECK: cset {{w[0-9]+}}, eq 44 %res = cmpxchg i32* %addr, i32 %desired, i32 %new seq_cst monotonic 45 ret { i32, i1 } %res 46} 47 48define { i64, i1 } @test_cmpxchg_64(i64* %addr, i64 %desired, i64 %new) nounwind { 49; CHECK-LABEL: test_cmpxchg_64: 50; CHECK: [[RETRY:.LBB[0-9]+_[0-9]+]]: 51; CHECK: ldaxr [[OLD:x[0-9]+]], [x0] 52; CHECK: cmp [[OLD]], x1 53; CHECK: b.ne [[DONE:.LBB[0-9]+_[0-9]+]] 54; CHECK: stlxr [[STATUS:w[3-9]]], x2, [x0] 55; CHECK: cbnz [[STATUS]], [[RETRY]] 56; CHECK: [[DONE]]: 57; CHECK: subs {{x[0-9]+}}, [[OLD]], x1 58; CHECK: cset {{w[0-9]+}}, eq 59 %res = cmpxchg i64* %addr, i64 %desired, i64 %new seq_cst monotonic 60 ret { i64, i1 } %res 61} 62 63define { i128, i1 } @test_cmpxchg_128(i128* %addr, i128 %desired, i128 %new) nounwind { 64; CHECK-LABEL: test_cmpxchg_128: 65; CHECK: [[RETRY:.LBB[0-9]+_[0-9]+]]: 66; CHECK: ldaxp [[OLD_LO:x[0-9]+]], [[OLD_HI:x[0-9]+]], [x0] 67; CHECK: cmp [[OLD_LO]], x2 68; CHECK: sbcs xzr, [[OLD_HI]], x3 69; CHECK: b.ne [[DONE:.LBB[0-9]+_[0-9]+]] 70; CHECK: stlxp [[STATUS:w[0-9]+]], x4, x5, [x0] 71; CHECK: cbnz [[STATUS]], [[RETRY]] 72; CHECK: [[DONE]]: 73 %res = cmpxchg i128* %addr, i128 %desired, i128 %new seq_cst monotonic 74 ret { i128, i1 } %res 75} 76