Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / PowerPC / quadword-atomics.c
blobbff03b25d27ee9ee846808f33892bcc672d8e5de
1 // RUN: %clang_cc1 -Werror -Wno-atomic-alignment -triple powerpc64le-linux-gnu \
2 // RUN: -target-cpu pwr8 -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC64-QUADWORD-ATOMICS
3 // RUN: %clang_cc1 -Werror -Wno-atomic-alignment -triple powerpc64le-linux-gnu \
4 // RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC64
5 // RUN: %clang_cc1 -Werror -Wno-atomic-alignment -triple powerpc64-unknown-aix \
6 // RUN: -target-cpu pwr7 -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC64
7 // RUN: %clang_cc1 -Werror -Wno-atomic-alignment -triple powerpc64-unknown-aix \
8 // RUN: -target-cpu pwr8 -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC64
9 // RUN: %clang_cc1 -Werror -Wno-atomic-alignment -triple powerpc64-unknown-aix \
10 // RUN: -mabi=quadword-atomics -target-cpu pwr8 -emit-llvm -o - %s | FileCheck %s \
11 // RUN: --check-prefix=PPC64-QUADWORD-ATOMICS
14 typedef struct {
15 char x[16];
16 } Q;
18 typedef _Atomic(Q) AtomicQ;
20 typedef __int128_t int128_t;
22 // PPC64-QUADWORD-ATOMICS-LABEL: @test_load(
23 // PPC64-QUADWORD-ATOMICS: [[TMP3:%.*]] = load atomic i128, ptr [[TMP1:%.*]] acquire, align 16
25 // PPC64-LABEL: @test_load(
26 // PPC64: call void @__atomic_load(i64 noundef 16, ptr noundef [[TMP3:%.*]], ptr noundef [[TMP4:%.*]], i32 noundef signext 2)
28 Q test_load(AtomicQ *ptr) {
29 // expected-no-diagnostics
30 return __c11_atomic_load(ptr, __ATOMIC_ACQUIRE);
33 // PPC64-QUADWORD-ATOMICS-LABEL: @test_store(
34 // PPC64-QUADWORD-ATOMICS: store atomic i128 [[TMP6:%.*]], ptr [[TMP4:%.*]] release, align 16
36 // PPC64-LABEL: @test_store(
37 // PPC64: call void @__atomic_store(i64 noundef 16, ptr noundef [[TMP6:%.*]], ptr noundef [[TMP7:%.*]], i32 noundef signext 3)
39 void test_store(Q val, AtomicQ *ptr) {
40 // expected-no-diagnostics
41 __c11_atomic_store(ptr, val, __ATOMIC_RELEASE);
44 // PPC64-QUADWORD-ATOMICS-LABEL: @test_add(
45 // PPC64-QUADWORD-ATOMICS: [[TMP3:%.*]] = atomicrmw add ptr [[TMP0:%.*]], i128 [[TMP2:%.*]] monotonic, align 16
47 // PPC64-LABEL: @test_add(
48 // PPC64: [[CALL:%.*]] = call i128 @__atomic_fetch_add_16(ptr noundef [[TMP2:%.*]], i128 noundef [[TMP3:%.*]], i32 noundef signext 0)
50 void test_add(_Atomic(int128_t) *ptr, int128_t x) {
51 // expected-no-diagnostics
52 __c11_atomic_fetch_add(ptr, x, __ATOMIC_RELAXED);
55 // PPC64-QUADWORD-ATOMICS-LABEL: @test_xchg(
56 // PPC64-QUADWORD-ATOMICS: [[TMP8:%.*]] = atomicrmw xchg ptr [[TMP4:%.*]], i128 [[TMP7:%.*]] seq_cst, align 16
58 // PPC64-LABEL: @test_xchg(
59 // PPC64: call void @__atomic_exchange(i64 noundef 16, ptr noundef [[TMP7:%.*]], ptr noundef [[TMP8:%.*]], ptr noundef [[TMP9:%.*]], i32 noundef signext 5)
61 Q test_xchg(AtomicQ *ptr, Q new) {
62 // expected-no-diagnostics
63 return __c11_atomic_exchange(ptr, new, __ATOMIC_SEQ_CST);
66 // PPC64-QUADWORD-ATOMICS-LABEL: @test_cmpxchg(
67 // PPC64-QUADWORD-ATOMICS: [[TMP10:%.*]] = cmpxchg ptr [[TMP5:%.*]], i128 [[TMP8:%.*]], i128 [[TMP9:%.*]] seq_cst monotonic, align 16
69 // PPC64-LABEL: @test_cmpxchg(
70 // PPC64: [[CALL:%.*]] = call zeroext i1 @__atomic_compare_exchange(i64 noundef 16, ptr noundef [[TMP8:%.*]], ptr noundef [[TMP9:%.*]], ptr noundef [[TMP10:%.*]], i32 noundef signext 5, i32 noundef signext 0)
72 int test_cmpxchg(AtomicQ *ptr, Q *cmp, Q new) {
73 // expected-no-diagnostics
74 return __c11_atomic_compare_exchange_strong(ptr, cmp, new, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED);
77 // PPC64-QUADWORD-ATOMICS-LABEL: @test_cmpxchg_weak(
78 // PPC64-QUADWORD-ATOMICS: [[TMP10:%.*]] = cmpxchg weak ptr [[TMP5:%.*]], i128 [[TMP8:%.*]], i128 [[TMP9:%.*]] seq_cst monotonic, align 16
80 // PPC64-LABEL: @test_cmpxchg_weak(
81 // PPC64: [[CALL:%.*]] = call zeroext i1 @__atomic_compare_exchange(i64 noundef 16, ptr noundef [[TMP8:%.*]], ptr noundef [[TMP9:%.*]], ptr noundef [[TMP10:%.*]], i32 noundef signext 5, i32 noundef signext 0)
83 int test_cmpxchg_weak(AtomicQ *ptr, Q *cmp, Q new) {
84 // expected-no-diagnostics
85 return __c11_atomic_compare_exchange_weak(ptr, cmp, new, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED);
88 // PPC64-QUADWORD-ATOMICS-LABEL: @is_lock_free(
89 // PPC64-QUADWORD-ATOMICS: ret i32 1
91 // PPC64-LABEL: @is_lock_free(
92 // PPC64: [[CALL:%.*]] = call zeroext i1 @__atomic_is_lock_free(i64 noundef 16, ptr noundef null)
94 int is_lock_free() {
95 AtomicQ q;
96 // expected-no-diagnostics
97 return __c11_atomic_is_lock_free(sizeof(q));