@@ -75,6 +75,35 @@ void load(int *ptr) {
7575// OGCG: %{{.+}} = load atomic i32, ptr %{{.+}} seq_cst, align 4
7676// OGCG: }
7777
78+ void load_n (int * ptr ) {
79+ int a ;
80+ a = __atomic_load_n (ptr , __ATOMIC_RELAXED );
81+ a = __atomic_load_n (ptr , __ATOMIC_CONSUME );
82+ a = __atomic_load_n (ptr , __ATOMIC_ACQUIRE );
83+ a = __atomic_load_n (ptr , __ATOMIC_SEQ_CST );
84+ }
85+
86+ // CIR-LABEL: @load_n
87+ // CIR: %{{.+}} = cir.load align(4) atomic(relaxed) %{{.+}} : !cir.ptr<!s32i>, !s32i
88+ // CIR: %{{.+}} = cir.load align(4) atomic(consume) %{{.+}} : !cir.ptr<!s32i>, !s32i
89+ // CIR: %{{.+}} = cir.load align(4) atomic(acquire) %{{.+}} : !cir.ptr<!s32i>, !s32i
90+ // CIR: %{{.+}} = cir.load align(4) atomic(seq_cst) %{{.+}} : !cir.ptr<!s32i>, !s32i
91+ // CIR: }
92+
93+ // LLVM-LABEL: @load_n
94+ // LLVM: %{{.+}} = load atomic i32, ptr %{{.+}} monotonic, align 4
95+ // LLVM: %{{.+}} = load atomic i32, ptr %{{.+}} acquire, align 4
96+ // LLVM: %{{.+}} = load atomic i32, ptr %{{.+}} acquire, align 4
97+ // LLVM: %{{.+}} = load atomic i32, ptr %{{.+}} seq_cst, align 4
98+ // LLVM: }
99+
100+ // OGCG-LABEL: @load_n
101+ // OGCG: %{{.+}} = load atomic i32, ptr %{{.+}} monotonic, align 4
102+ // OGCG: %{{.+}} = load atomic i32, ptr %{{.+}} acquire, align 4
103+ // OGCG: %{{.+}} = load atomic i32, ptr %{{.+}} acquire, align 4
104+ // OGCG: %{{.+}} = load atomic i32, ptr %{{.+}} seq_cst, align 4
105+ // OGCG: }
106+
78107void c11_load (_Atomic (int ) * ptr ) {
79108 __c11_atomic_load (ptr , __ATOMIC_RELAXED );
80109 __c11_atomic_load (ptr , __ATOMIC_CONSUME );
@@ -127,6 +156,30 @@ void store(int *ptr, int x) {
127156// OGCG: store atomic i32 %{{.+}}, ptr %{{.+}} seq_cst, align 4
128157// OGCG: }
129158
159+ void store_n (int * ptr , int x ) {
160+ __atomic_store_n (ptr , x , __ATOMIC_RELAXED );
161+ __atomic_store_n (ptr , x , __ATOMIC_RELEASE );
162+ __atomic_store_n (ptr , x , __ATOMIC_SEQ_CST );
163+ }
164+
165+ // CIR-LABEL: @store_n
166+ // CIR: cir.store align(4) atomic(relaxed) %{{.+}}, %{{.+}} : !s32i, !cir.ptr<!s32i>
167+ // CIR: cir.store align(4) atomic(release) %{{.+}}, %{{.+}} : !s32i, !cir.ptr<!s32i>
168+ // CIR: cir.store align(4) atomic(seq_cst) %{{.+}}, %{{.+}} : !s32i, !cir.ptr<!s32i>
169+ // CIR: }
170+
171+ // LLVM-LABEL: @store_n
172+ // LLVM: store atomic i32 %{{.+}}, ptr %{{.+}} monotonic, align 4
173+ // LLVM: store atomic i32 %{{.+}}, ptr %{{.+}} release, align 4
174+ // LLVM: store atomic i32 %{{.+}}, ptr %{{.+}} seq_cst, align 4
175+ // LLVM: }
176+
177+ // OGCG-LABEL: @store_n
178+ // OGCG: store atomic i32 %{{.+}}, ptr %{{.+}} monotonic, align 4
179+ // OGCG: store atomic i32 %{{.+}}, ptr %{{.+}} release, align 4
180+ // OGCG: store atomic i32 %{{.+}}, ptr %{{.+}} seq_cst, align 4
181+ // OGCG: }
182+
130183void c11_store (_Atomic (int ) * ptr , int x ) {
131184 __c11_atomic_store (ptr , x , __ATOMIC_RELAXED );
132185 __c11_atomic_store (ptr , x , __ATOMIC_RELEASE );
0 commit comments