1; RUN: llc < %s -march=ppc64 | FileCheck %s 2; RUN: llc < %s -march=ppc64 -mcpu=pwr7 | FileCheck %s 3; RUN: llc < %s -march=ppc64 -mcpu=pwr8 | FileCheck %s -check-prefix=CHECK-P8U 4 5define i64 @exchange_and_add(i64* %mem, i64 %val) nounwind { 6; CHECK-LABEL: exchange_and_add: 7; CHECK: ldarx 8 %tmp = atomicrmw add i64* %mem, i64 %val monotonic 9; CHECK: stdcx. 10 ret i64 %tmp 11} 12 13define i8 @exchange_and_add8(i8* %mem, i8 %val) nounwind { 14; CHECK-LABEL: exchange_and_add8: 15; CHECK-P8U: lbarx 16 %tmp = atomicrmw add i8* %mem, i8 %val monotonic 17; CHECK-P8U: stbcx. 18 ret i8 %tmp 19} 20 21define i16 @exchange_and_add16(i16* %mem, i16 %val) nounwind { 22; CHECK-LABEL: exchange_and_add16: 23; CHECK-P8U: lharx 24 %tmp = atomicrmw add i16* %mem, i16 %val monotonic 25; CHECK-P8U: sthcx. 26 ret i16 %tmp 27} 28 29define i64 @exchange_and_cmp(i64* %mem) nounwind { 30; CHECK-LABEL: exchange_and_cmp: 31; CHECK: ldarx 32 %tmppair = cmpxchg i64* %mem, i64 0, i64 1 monotonic monotonic 33 %tmp = extractvalue { i64, i1 } %tmppair, 0 34; CHECK: stdcx. 35; CHECK: stdcx. 36 ret i64 %tmp 37} 38 39define i8 @exchange_and_cmp8(i8* %mem) nounwind { 40; CHECK-LABEL: exchange_and_cmp8: 41; CHECK-P8U: lbarx 42 %tmppair = cmpxchg i8* %mem, i8 0, i8 1 monotonic monotonic 43 %tmp = extractvalue { i8, i1 } %tmppair, 0 44; CHECK-P8U: stbcx. 45; CHECK-P8U: stbcx. 46 ret i8 %tmp 47} 48 49define i16 @exchange_and_cmp16(i16* %mem) nounwind { 50; CHECK-LABEL: exchange_and_cmp16: 51; CHECK-P8U: lharx 52 %tmppair = cmpxchg i16* %mem, i16 0, i16 1 monotonic monotonic 53 %tmp = extractvalue { i16, i1 } %tmppair, 0 54; CHECK-P8U: sthcx. 55; CHECK-P8U: sthcx. 56 ret i16 %tmp 57} 58 59define i64 @exchange(i64* %mem, i64 %val) nounwind { 60; CHECK-LABEL: exchange: 61; CHECK: ldarx 62 %tmp = atomicrmw xchg i64* %mem, i64 1 monotonic 63; CHECK: stdcx. 64 ret i64 %tmp 65} 66 67define i8 @exchange8(i8* %mem, i8 %val) nounwind { 68; CHECK-LABEL: exchange8: 69; CHECK-P8U: lbarx 70 %tmp = atomicrmw xchg i8* %mem, i8 1 monotonic 71; CHECK-P8U: stbcx. 72 ret i8 %tmp 73} 74 75define i16 @exchange16(i16* %mem, i16 %val) nounwind { 76; CHECK-LABEL: exchange16: 77; CHECK-P8U: lharx 78 %tmp = atomicrmw xchg i16* %mem, i16 1 monotonic 79; CHECK-P8U: sthcx. 80 ret i16 %tmp 81} 82 83define void @atomic_store(i64* %mem, i64 %val) nounwind { 84entry: 85; CHECK: @atomic_store 86 store atomic i64 %val, i64* %mem release, align 64 87; CHECK: lwsync 88; CHECK-NOT: stdcx 89; CHECK: std 90 ret void 91} 92 93define i64 @atomic_load(i64* %mem) nounwind { 94entry: 95; CHECK: @atomic_load 96 %tmp = load atomic i64, i64* %mem acquire, align 64 97; CHECK-NOT: ldarx 98; CHECK: ld 99; CHECK: lwsync 100 ret i64 %tmp 101} 102 103