xref: /llvm-project/llvm/test/CodeGen/VE/Scalar/atomic_cmp_swap.ll (revision 7b3bbd83c0c24087072ec5b22a76799ab31f87d5)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=ve | FileCheck %s
3
4;;; Test atomic compare and exchange weak for all types and all memory order
5;;;
6;;; Note:
7;;;   - We test i1/i8/i16/i32/i64/i128/u8/u16/u32/u64/u128.
8;;;   - We test relaxed, acquire, and seq_cst.
9;;;   - We test only exchange with variables since VE doesn't have exchange
10;;;     instructions with immediate values.
11;;;   - We test against an object, a stack object, and a global variable.
12
13%"struct.std::__1::atomic" = type { %"struct.std::__1::__atomic_base" }
14%"struct.std::__1::__atomic_base" = type { %"struct.std::__1::__cxx_atomic_impl" }
15%"struct.std::__1::__cxx_atomic_impl" = type { %"struct.std::__1::__cxx_atomic_base_impl" }
16%"struct.std::__1::__cxx_atomic_base_impl" = type { i8 }
17%"struct.std::__1::atomic.0" = type { %"struct.std::__1::__atomic_base.1" }
18%"struct.std::__1::__atomic_base.1" = type { %"struct.std::__1::__atomic_base.2" }
19%"struct.std::__1::__atomic_base.2" = type { %"struct.std::__1::__cxx_atomic_impl.3" }
20%"struct.std::__1::__cxx_atomic_impl.3" = type { %"struct.std::__1::__cxx_atomic_base_impl.4" }
21%"struct.std::__1::__cxx_atomic_base_impl.4" = type { i8 }
22%"struct.std::__1::atomic.5" = type { %"struct.std::__1::__atomic_base.6" }
23%"struct.std::__1::__atomic_base.6" = type { %"struct.std::__1::__atomic_base.7" }
24%"struct.std::__1::__atomic_base.7" = type { %"struct.std::__1::__cxx_atomic_impl.8" }
25%"struct.std::__1::__cxx_atomic_impl.8" = type { %"struct.std::__1::__cxx_atomic_base_impl.9" }
26%"struct.std::__1::__cxx_atomic_base_impl.9" = type { i8 }
27%"struct.std::__1::atomic.10" = type { %"struct.std::__1::__atomic_base.11" }
28%"struct.std::__1::__atomic_base.11" = type { %"struct.std::__1::__atomic_base.12" }
29%"struct.std::__1::__atomic_base.12" = type { %"struct.std::__1::__cxx_atomic_impl.13" }
30%"struct.std::__1::__cxx_atomic_impl.13" = type { %"struct.std::__1::__cxx_atomic_base_impl.14" }
31%"struct.std::__1::__cxx_atomic_base_impl.14" = type { i16 }
32%"struct.std::__1::atomic.15" = type { %"struct.std::__1::__atomic_base.16" }
33%"struct.std::__1::__atomic_base.16" = type { %"struct.std::__1::__atomic_base.17" }
34%"struct.std::__1::__atomic_base.17" = type { %"struct.std::__1::__cxx_atomic_impl.18" }
35%"struct.std::__1::__cxx_atomic_impl.18" = type { %"struct.std::__1::__cxx_atomic_base_impl.19" }
36%"struct.std::__1::__cxx_atomic_base_impl.19" = type { i16 }
37%"struct.std::__1::atomic.20" = type { %"struct.std::__1::__atomic_base.21" }
38%"struct.std::__1::__atomic_base.21" = type { %"struct.std::__1::__atomic_base.22" }
39%"struct.std::__1::__atomic_base.22" = type { %"struct.std::__1::__cxx_atomic_impl.23" }
40%"struct.std::__1::__cxx_atomic_impl.23" = type { %"struct.std::__1::__cxx_atomic_base_impl.24" }
41%"struct.std::__1::__cxx_atomic_base_impl.24" = type { i32 }
42%"struct.std::__1::atomic.25" = type { %"struct.std::__1::__atomic_base.26" }
43%"struct.std::__1::__atomic_base.26" = type { %"struct.std::__1::__atomic_base.27" }
44%"struct.std::__1::__atomic_base.27" = type { %"struct.std::__1::__cxx_atomic_impl.28" }
45%"struct.std::__1::__cxx_atomic_impl.28" = type { %"struct.std::__1::__cxx_atomic_base_impl.29" }
46%"struct.std::__1::__cxx_atomic_base_impl.29" = type { i32 }
47%"struct.std::__1::atomic.30" = type { %"struct.std::__1::__atomic_base.31" }
48%"struct.std::__1::__atomic_base.31" = type { %"struct.std::__1::__atomic_base.32" }
49%"struct.std::__1::__atomic_base.32" = type { %"struct.std::__1::__cxx_atomic_impl.33" }
50%"struct.std::__1::__cxx_atomic_impl.33" = type { %"struct.std::__1::__cxx_atomic_base_impl.34" }
51%"struct.std::__1::__cxx_atomic_base_impl.34" = type { i64 }
52%"struct.std::__1::atomic.35" = type { %"struct.std::__1::__atomic_base.36" }
53%"struct.std::__1::__atomic_base.36" = type { %"struct.std::__1::__atomic_base.37" }
54%"struct.std::__1::__atomic_base.37" = type { %"struct.std::__1::__cxx_atomic_impl.38" }
55%"struct.std::__1::__cxx_atomic_impl.38" = type { %"struct.std::__1::__cxx_atomic_base_impl.39" }
56%"struct.std::__1::__cxx_atomic_base_impl.39" = type { i64 }
57%"struct.std::__1::atomic.40" = type { %"struct.std::__1::__atomic_base.41" }
58%"struct.std::__1::__atomic_base.41" = type { %"struct.std::__1::__atomic_base.42" }
59%"struct.std::__1::__atomic_base.42" = type { %"struct.std::__1::__cxx_atomic_impl.43" }
60%"struct.std::__1::__cxx_atomic_impl.43" = type { %"struct.std::__1::__cxx_atomic_base_impl.44" }
61%"struct.std::__1::__cxx_atomic_base_impl.44" = type { i128 }
62%"struct.std::__1::atomic.45" = type { %"struct.std::__1::__atomic_base.46" }
63%"struct.std::__1::__atomic_base.46" = type { %"struct.std::__1::__atomic_base.47" }
64%"struct.std::__1::__atomic_base.47" = type { %"struct.std::__1::__cxx_atomic_impl.48" }
65%"struct.std::__1::__cxx_atomic_impl.48" = type { %"struct.std::__1::__cxx_atomic_base_impl.49" }
66%"struct.std::__1::__cxx_atomic_base_impl.49" = type { i128 }
67
68@gv_i1 = global %"struct.std::__1::atomic" zeroinitializer, align 4
69@gv_i8 = global %"struct.std::__1::atomic.0" zeroinitializer, align 4
70@gv_u8 = global %"struct.std::__1::atomic.5" zeroinitializer, align 4
71@gv_i16 = global %"struct.std::__1::atomic.10" zeroinitializer, align 4
72@gv_u16 = global %"struct.std::__1::atomic.15" zeroinitializer, align 4
73@gv_i32 = global %"struct.std::__1::atomic.20" zeroinitializer, align 4
74@gv_u32 = global %"struct.std::__1::atomic.25" zeroinitializer, align 4
75@gv_i64 = global %"struct.std::__1::atomic.30" zeroinitializer, align 8
76@gv_u64 = global %"struct.std::__1::atomic.35" zeroinitializer, align 8
77@gv_i128 = global %"struct.std::__1::atomic.40" zeroinitializer, align 16
78@gv_u128 = global %"struct.std::__1::atomic.45" zeroinitializer, align 16
79
80; Function Attrs: nofree norecurse nounwind mustprogress
81define zeroext i1 @_Z26atomic_cmp_swap_relaxed_i1RNSt3__16atomicIbEERbb(ptr nocapture nonnull align 1 dereferenceable(1) %arg, ptr nocapture nonnull align 1 dereferenceable(1) %arg1, i1 zeroext %arg2) {
82; CHECK-LABEL: _Z26atomic_cmp_swap_relaxed_i1RNSt3__16atomicIbEERbb:
83; CHECK:       # %bb.0: # %bb
84; CHECK-NEXT:    ld1b.zx %s4, (, %s1)
85; CHECK-NEXT:    and %s3, -4, %s0
86; CHECK-NEXT:    and %s0, 3, %s0
87; CHECK-NEXT:    sla.w.sx %s0, %s0, 3
88; CHECK-NEXT:    ldl.sx %s5, (, %s3)
89; CHECK-NEXT:    sla.w.sx %s6, (56)0, %s0
90; CHECK-NEXT:    sla.w.sx %s2, %s2, %s0
91; CHECK-NEXT:    sla.w.sx %s4, %s4, %s0
92; CHECK-NEXT:    nnd %s5, %s6, %s5
93; CHECK-NEXT:    and %s5, %s5, (32)0
94; CHECK-NEXT:    or %s2, %s5, %s2
95; CHECK-NEXT:    or %s4, %s5, %s4
96; CHECK-NEXT:    cas.w %s2, (%s3), %s4
97; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s4
98; CHECK-NEXT:    or %s3, 0, (0)1
99; CHECK-NEXT:    cmov.w.eq %s3, (63)0, %s4
100; CHECK-NEXT:    brne.w 0, %s3, .LBB0_2
101; CHECK-NEXT:  # %bb.1: # %bb7
102; CHECK-NEXT:    and %s2, %s2, (32)0
103; CHECK-NEXT:    srl %s0, %s2, %s0
104; CHECK-NEXT:    st1b %s0, (, %s1)
105; CHECK-NEXT:  .LBB0_2: # %bb9
106; CHECK-NEXT:    adds.w.zx %s0, %s3, (0)1
107; CHECK-NEXT:    b.l.t (, %s10)
108bb:
109  %i = zext i1 %arg2 to i8
110  %i4 = load i8, ptr %arg1, align 1
111  %i5 = cmpxchg weak ptr %arg, i8 %i4, i8 %i monotonic monotonic, align 1
112  %i6 = extractvalue { i8, i1 } %i5, 1
113  br i1 %i6, label %bb9, label %bb7
114
115bb7:                                              ; preds = %bb
116  %i8 = extractvalue { i8, i1 } %i5, 0
117  store i8 %i8, ptr %arg1, align 1
118  br label %bb9
119
120bb9:                                              ; preds = %bb7, %bb
121  ret i1 %i6
122}
123
124; Function Attrs: nofree norecurse nounwind mustprogress
125define signext i8 @_Z26atomic_cmp_swap_relaxed_i8RNSt3__16atomicIcEERcc(ptr nocapture nonnull align 1 dereferenceable(1) %arg, ptr nocapture nonnull align 1 dereferenceable(1) %arg1, i8 signext %arg2) {
126; CHECK-LABEL: _Z26atomic_cmp_swap_relaxed_i8RNSt3__16atomicIcEERcc:
127; CHECK:       # %bb.0: # %bb
128; CHECK-NEXT:    ld1b.zx %s4, (, %s1)
129; CHECK-NEXT:    and %s3, -4, %s0
130; CHECK-NEXT:    and %s0, 3, %s0
131; CHECK-NEXT:    sla.w.sx %s0, %s0, 3
132; CHECK-NEXT:    sla.w.sx %s5, (56)0, %s0
133; CHECK-NEXT:    ldl.sx %s6, (, %s3)
134; CHECK-NEXT:    and %s2, %s2, (56)0
135; CHECK-NEXT:    sla.w.sx %s2, %s2, %s0
136; CHECK-NEXT:    sla.w.sx %s4, %s4, %s0
137; CHECK-NEXT:    nnd %s5, %s5, %s6
138; CHECK-NEXT:    and %s5, %s5, (32)0
139; CHECK-NEXT:    or %s2, %s5, %s2
140; CHECK-NEXT:    or %s4, %s5, %s4
141; CHECK-NEXT:    cas.w %s2, (%s3), %s4
142; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s4
143; CHECK-NEXT:    or %s3, 0, (0)1
144; CHECK-NEXT:    cmov.w.eq %s3, (63)0, %s4
145; CHECK-NEXT:    brne.w 0, %s3, .LBB1_2
146; CHECK-NEXT:  # %bb.1: # %bb6
147; CHECK-NEXT:    and %s2, %s2, (32)0
148; CHECK-NEXT:    srl %s0, %s2, %s0
149; CHECK-NEXT:    st1b %s0, (, %s1)
150; CHECK-NEXT:  .LBB1_2: # %bb8
151; CHECK-NEXT:    adds.w.zx %s0, %s3, (0)1
152; CHECK-NEXT:    b.l.t (, %s10)
153bb:
154  %i3 = load i8, ptr %arg1, align 1
155  %i4 = cmpxchg weak ptr %arg, i8 %i3, i8 %arg2 monotonic monotonic, align 1
156  %i5 = extractvalue { i8, i1 } %i4, 1
157  br i1 %i5, label %bb8, label %bb6
158
159bb6:                                              ; preds = %bb
160  %i7 = extractvalue { i8, i1 } %i4, 0
161  store i8 %i7, ptr %arg1, align 1
162  br label %bb8
163
164bb8:                                              ; preds = %bb6, %bb
165  %i9 = zext i1 %i5 to i8
166  ret i8 %i9
167}
168
169; Function Attrs: nofree norecurse nounwind mustprogress
170define zeroext i8 @_Z26atomic_cmp_swap_relaxed_u8RNSt3__16atomicIhEERhh(ptr nocapture nonnull align 1 dereferenceable(1) %arg, ptr nocapture nonnull align 1 dereferenceable(1) %arg1, i8 zeroext %arg2) {
171; CHECK-LABEL: _Z26atomic_cmp_swap_relaxed_u8RNSt3__16atomicIhEERhh:
172; CHECK:       # %bb.0: # %bb
173; CHECK-NEXT:    ld1b.zx %s4, (, %s1)
174; CHECK-NEXT:    and %s3, -4, %s0
175; CHECK-NEXT:    and %s0, 3, %s0
176; CHECK-NEXT:    sla.w.sx %s0, %s0, 3
177; CHECK-NEXT:    ldl.sx %s5, (, %s3)
178; CHECK-NEXT:    sla.w.sx %s6, (56)0, %s0
179; CHECK-NEXT:    sla.w.sx %s2, %s2, %s0
180; CHECK-NEXT:    sla.w.sx %s4, %s4, %s0
181; CHECK-NEXT:    nnd %s5, %s6, %s5
182; CHECK-NEXT:    and %s5, %s5, (32)0
183; CHECK-NEXT:    or %s2, %s5, %s2
184; CHECK-NEXT:    or %s4, %s5, %s4
185; CHECK-NEXT:    cas.w %s2, (%s3), %s4
186; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s4
187; CHECK-NEXT:    or %s3, 0, (0)1
188; CHECK-NEXT:    cmov.w.eq %s3, (63)0, %s4
189; CHECK-NEXT:    brne.w 0, %s3, .LBB2_2
190; CHECK-NEXT:  # %bb.1: # %bb6
191; CHECK-NEXT:    and %s2, %s2, (32)0
192; CHECK-NEXT:    srl %s0, %s2, %s0
193; CHECK-NEXT:    st1b %s0, (, %s1)
194; CHECK-NEXT:  .LBB2_2: # %bb8
195; CHECK-NEXT:    adds.w.zx %s0, %s3, (0)1
196; CHECK-NEXT:    b.l.t (, %s10)
197bb:
198  %i3 = load i8, ptr %arg1, align 1
199  %i4 = cmpxchg weak ptr %arg, i8 %i3, i8 %arg2 monotonic monotonic, align 1
200  %i5 = extractvalue { i8, i1 } %i4, 1
201  br i1 %i5, label %bb8, label %bb6
202
203bb6:                                              ; preds = %bb
204  %i7 = extractvalue { i8, i1 } %i4, 0
205  store i8 %i7, ptr %arg1, align 1
206  br label %bb8
207
208bb8:                                              ; preds = %bb6, %bb
209  %i9 = zext i1 %i5 to i8
210  ret i8 %i9
211}
212
213; Function Attrs: nofree norecurse nounwind mustprogress
214define signext i16 @_Z27atomic_cmp_swap_relaxed_i16RNSt3__16atomicIsEERss(ptr nocapture nonnull align 2 dereferenceable(2) %arg, ptr nocapture nonnull align 2 dereferenceable(2) %arg1, i16 signext %arg2) {
215; CHECK-LABEL: _Z27atomic_cmp_swap_relaxed_i16RNSt3__16atomicIsEERss:
216; CHECK:       # %bb.0: # %bb
217; CHECK-NEXT:    ld2b.zx %s4, (, %s1)
218; CHECK-NEXT:    and %s3, -4, %s0
219; CHECK-NEXT:    and %s0, 3, %s0
220; CHECK-NEXT:    sla.w.sx %s0, %s0, 3
221; CHECK-NEXT:    sla.w.sx %s5, (48)0, %s0
222; CHECK-NEXT:    ldl.sx %s6, (, %s3)
223; CHECK-NEXT:    and %s2, %s2, (48)0
224; CHECK-NEXT:    sla.w.sx %s2, %s2, %s0
225; CHECK-NEXT:    sla.w.sx %s4, %s4, %s0
226; CHECK-NEXT:    nnd %s5, %s5, %s6
227; CHECK-NEXT:    and %s5, %s5, (32)0
228; CHECK-NEXT:    or %s2, %s5, %s2
229; CHECK-NEXT:    or %s4, %s5, %s4
230; CHECK-NEXT:    cas.w %s2, (%s3), %s4
231; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s4
232; CHECK-NEXT:    or %s3, 0, (0)1
233; CHECK-NEXT:    cmov.w.eq %s3, (63)0, %s4
234; CHECK-NEXT:    brne.w 0, %s3, .LBB3_2
235; CHECK-NEXT:  # %bb.1: # %bb6
236; CHECK-NEXT:    and %s2, %s2, (32)0
237; CHECK-NEXT:    srl %s0, %s2, %s0
238; CHECK-NEXT:    st2b %s0, (, %s1)
239; CHECK-NEXT:  .LBB3_2: # %bb8
240; CHECK-NEXT:    adds.w.zx %s0, %s3, (0)1
241; CHECK-NEXT:    b.l.t (, %s10)
242bb:
243  %i3 = load i16, ptr %arg1, align 2
244  %i4 = cmpxchg weak ptr %arg, i16 %i3, i16 %arg2 monotonic monotonic, align 2
245  %i5 = extractvalue { i16, i1 } %i4, 1
246  br i1 %i5, label %bb8, label %bb6
247
248bb6:                                              ; preds = %bb
249  %i7 = extractvalue { i16, i1 } %i4, 0
250  store i16 %i7, ptr %arg1, align 2
251  br label %bb8
252
253bb8:                                              ; preds = %bb6, %bb
254  %i9 = zext i1 %i5 to i16
255  ret i16 %i9
256}
257
258; Function Attrs: nofree norecurse nounwind mustprogress
259define zeroext i16 @_Z27atomic_cmp_swap_relaxed_u16RNSt3__16atomicItEERtt(ptr nocapture nonnull align 2 dereferenceable(2) %arg, ptr nocapture nonnull align 2 dereferenceable(2) %arg1, i16 zeroext %arg2) {
260; CHECK-LABEL: _Z27atomic_cmp_swap_relaxed_u16RNSt3__16atomicItEERtt:
261; CHECK:       # %bb.0: # %bb
262; CHECK-NEXT:    ld2b.zx %s4, (, %s1)
263; CHECK-NEXT:    and %s3, -4, %s0
264; CHECK-NEXT:    and %s0, 3, %s0
265; CHECK-NEXT:    sla.w.sx %s0, %s0, 3
266; CHECK-NEXT:    ldl.sx %s5, (, %s3)
267; CHECK-NEXT:    sla.w.sx %s6, (48)0, %s0
268; CHECK-NEXT:    sla.w.sx %s2, %s2, %s0
269; CHECK-NEXT:    sla.w.sx %s4, %s4, %s0
270; CHECK-NEXT:    nnd %s5, %s6, %s5
271; CHECK-NEXT:    and %s5, %s5, (32)0
272; CHECK-NEXT:    or %s2, %s5, %s2
273; CHECK-NEXT:    or %s4, %s5, %s4
274; CHECK-NEXT:    cas.w %s2, (%s3), %s4
275; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s4
276; CHECK-NEXT:    or %s3, 0, (0)1
277; CHECK-NEXT:    cmov.w.eq %s3, (63)0, %s4
278; CHECK-NEXT:    brne.w 0, %s3, .LBB4_2
279; CHECK-NEXT:  # %bb.1: # %bb6
280; CHECK-NEXT:    and %s2, %s2, (32)0
281; CHECK-NEXT:    srl %s0, %s2, %s0
282; CHECK-NEXT:    st2b %s0, (, %s1)
283; CHECK-NEXT:  .LBB4_2: # %bb8
284; CHECK-NEXT:    adds.w.zx %s0, %s3, (0)1
285; CHECK-NEXT:    b.l.t (, %s10)
286bb:
287  %i3 = load i16, ptr %arg1, align 2
288  %i4 = cmpxchg weak ptr %arg, i16 %i3, i16 %arg2 monotonic monotonic, align 2
289  %i5 = extractvalue { i16, i1 } %i4, 1
290  br i1 %i5, label %bb8, label %bb6
291
292bb6:                                              ; preds = %bb
293  %i7 = extractvalue { i16, i1 } %i4, 0
294  store i16 %i7, ptr %arg1, align 2
295  br label %bb8
296
297bb8:                                              ; preds = %bb6, %bb
298  %i9 = zext i1 %i5 to i16
299  ret i16 %i9
300}
301
302; Function Attrs: nofree norecurse nounwind mustprogress
303define signext i32 @_Z27atomic_cmp_swap_relaxed_i32RNSt3__16atomicIiEERii(ptr nocapture nonnull align 4 dereferenceable(4) %arg, ptr nocapture nonnull align 4 dereferenceable(4) %arg1, i32 signext %arg2) {
304; CHECK-LABEL: _Z27atomic_cmp_swap_relaxed_i32RNSt3__16atomicIiEERii:
305; CHECK:       # %bb.0: # %bb
306; CHECK-NEXT:    ldl.sx %s3, (, %s1)
307; CHECK-NEXT:    cas.w %s2, (%s0), %s3
308; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s3
309; CHECK-NEXT:    or %s0, 0, (0)1
310; CHECK-NEXT:    cmov.w.eq %s0, (63)0, %s4
311; CHECK-NEXT:    breq.w %s2, %s3, .LBB5_2
312; CHECK-NEXT:  # %bb.1: # %bb6
313; CHECK-NEXT:    stl %s2, (, %s1)
314; CHECK-NEXT:  .LBB5_2: # %bb8
315; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
316; CHECK-NEXT:    b.l.t (, %s10)
317bb:
318  %i3 = load i32, ptr %arg1, align 4
319  %i4 = cmpxchg weak ptr %arg, i32 %i3, i32 %arg2 monotonic monotonic, align 4
320  %i5 = extractvalue { i32, i1 } %i4, 1
321  br i1 %i5, label %bb8, label %bb6
322
323bb6:                                              ; preds = %bb
324  %i7 = extractvalue { i32, i1 } %i4, 0
325  store i32 %i7, ptr %arg1, align 4
326  br label %bb8
327
328bb8:                                              ; preds = %bb6, %bb
329  %i9 = zext i1 %i5 to i32
330  ret i32 %i9
331}
332
333; Function Attrs: nofree norecurse nounwind mustprogress
334define zeroext i32 @_Z27atomic_cmp_swap_relaxed_u32RNSt3__16atomicIjEERjj(ptr nocapture nonnull align 4 dereferenceable(4) %arg, ptr nocapture nonnull align 4 dereferenceable(4) %arg1, i32 zeroext %arg2) {
335; CHECK-LABEL: _Z27atomic_cmp_swap_relaxed_u32RNSt3__16atomicIjEERjj:
336; CHECK:       # %bb.0: # %bb
337; CHECK-NEXT:    ldl.sx %s3, (, %s1)
338; CHECK-NEXT:    cas.w %s2, (%s0), %s3
339; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s3
340; CHECK-NEXT:    or %s0, 0, (0)1
341; CHECK-NEXT:    cmov.w.eq %s0, (63)0, %s4
342; CHECK-NEXT:    breq.w %s2, %s3, .LBB6_2
343; CHECK-NEXT:  # %bb.1: # %bb6
344; CHECK-NEXT:    stl %s2, (, %s1)
345; CHECK-NEXT:  .LBB6_2: # %bb8
346; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
347; CHECK-NEXT:    b.l.t (, %s10)
348bb:
349  %i3 = load i32, ptr %arg1, align 4
350  %i4 = cmpxchg weak ptr %arg, i32 %i3, i32 %arg2 monotonic monotonic, align 4
351  %i5 = extractvalue { i32, i1 } %i4, 1
352  br i1 %i5, label %bb8, label %bb6
353
354bb6:                                              ; preds = %bb
355  %i7 = extractvalue { i32, i1 } %i4, 0
356  store i32 %i7, ptr %arg1, align 4
357  br label %bb8
358
359bb8:                                              ; preds = %bb6, %bb
360  %i9 = zext i1 %i5 to i32
361  ret i32 %i9
362}
363
364; Function Attrs: nofree norecurse nounwind mustprogress
365define i64 @_Z27atomic_cmp_swap_relaxed_i64RNSt3__16atomicIlEERll(ptr nocapture nonnull align 8 dereferenceable(8) %arg, ptr nocapture nonnull align 8 dereferenceable(8) %arg1, i64 %arg2) {
366; CHECK-LABEL: _Z27atomic_cmp_swap_relaxed_i64RNSt3__16atomicIlEERll:
367; CHECK:       # %bb.0: # %bb
368; CHECK-NEXT:    ld %s3, (, %s1)
369; CHECK-NEXT:    cas.l %s2, (%s0), %s3
370; CHECK-NEXT:    cmps.l %s4, %s2, %s3
371; CHECK-NEXT:    or %s0, 0, (0)1
372; CHECK-NEXT:    cmov.l.eq %s0, (63)0, %s4
373; CHECK-NEXT:    breq.l %s2, %s3, .LBB7_2
374; CHECK-NEXT:  # %bb.1: # %bb6
375; CHECK-NEXT:    st %s2, (, %s1)
376; CHECK-NEXT:  .LBB7_2: # %bb8
377; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
378; CHECK-NEXT:    b.l.t (, %s10)
379bb:
380  %i3 = load i64, ptr %arg1, align 8
381  %i4 = cmpxchg weak ptr %arg, i64 %i3, i64 %arg2 monotonic monotonic, align 8
382  %i5 = extractvalue { i64, i1 } %i4, 1
383  br i1 %i5, label %bb8, label %bb6
384
385bb6:                                              ; preds = %bb
386  %i7 = extractvalue { i64, i1 } %i4, 0
387  store i64 %i7, ptr %arg1, align 8
388  br label %bb8
389
390bb8:                                              ; preds = %bb6, %bb
391  %i9 = zext i1 %i5 to i64
392  ret i64 %i9
393}
394
395; Function Attrs: nofree norecurse nounwind mustprogress
396define i64 @_Z27atomic_cmp_swap_relaxed_u64RNSt3__16atomicImEERmm(ptr nocapture nonnull align 8 dereferenceable(8) %arg, ptr nocapture nonnull align 8 dereferenceable(8) %arg1, i64 %arg2) {
397; CHECK-LABEL: _Z27atomic_cmp_swap_relaxed_u64RNSt3__16atomicImEERmm:
398; CHECK:       # %bb.0: # %bb
399; CHECK-NEXT:    ld %s3, (, %s1)
400; CHECK-NEXT:    cas.l %s2, (%s0), %s3
401; CHECK-NEXT:    cmps.l %s4, %s2, %s3
402; CHECK-NEXT:    or %s0, 0, (0)1
403; CHECK-NEXT:    cmov.l.eq %s0, (63)0, %s4
404; CHECK-NEXT:    breq.l %s2, %s3, .LBB8_2
405; CHECK-NEXT:  # %bb.1: # %bb6
406; CHECK-NEXT:    st %s2, (, %s1)
407; CHECK-NEXT:  .LBB8_2: # %bb8
408; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
409; CHECK-NEXT:    b.l.t (, %s10)
410bb:
411  %i3 = load i64, ptr %arg1, align 8
412  %i4 = cmpxchg weak ptr %arg, i64 %i3, i64 %arg2 monotonic monotonic, align 8
413  %i5 = extractvalue { i64, i1 } %i4, 1
414  br i1 %i5, label %bb8, label %bb6
415
416bb6:                                              ; preds = %bb
417  %i7 = extractvalue { i64, i1 } %i4, 0
418  store i64 %i7, ptr %arg1, align 8
419  br label %bb8
420
421bb8:                                              ; preds = %bb6, %bb
422  %i9 = zext i1 %i5 to i64
423  ret i64 %i9
424}
425
426; Function Attrs: nounwind mustprogress
427define i128 @_Z28atomic_cmp_swap_relaxed_i128RNSt3__16atomicInEERnn(ptr nonnull align 16 dereferenceable(16) %arg, ptr nonnull align 16 dereferenceable(16) %arg1, i128 %arg2) {
428; CHECK-LABEL: _Z28atomic_cmp_swap_relaxed_i128RNSt3__16atomicInEERnn:
429; CHECK:       # %bb.0: # %bb
430; CHECK-NEXT:    st %s9, (, %s11)
431; CHECK-NEXT:    st %s10, 8(, %s11)
432; CHECK-NEXT:    or %s9, 0, %s11
433; CHECK-NEXT:    lea %s11, -256(, %s11)
434; CHECK-NEXT:    brge.l.t %s11, %s8, .LBB9_2
435; CHECK-NEXT:  # %bb.1: # %bb
436; CHECK-NEXT:    ld %s61, 24(, %s14)
437; CHECK-NEXT:    or %s62, 0, %s0
438; CHECK-NEXT:    lea %s63, 315
439; CHECK-NEXT:    shm.l %s63, (%s61)
440; CHECK-NEXT:    shm.l %s8, 8(%s61)
441; CHECK-NEXT:    shm.l %s11, 16(%s61)
442; CHECK-NEXT:    monc
443; CHECK-NEXT:    or %s0, 0, %s62
444; CHECK-NEXT:  .LBB9_2: # %bb
445; CHECK-NEXT:    or %s6, 0, %s1
446; CHECK-NEXT:    or %s1, 0, %s0
447; CHECK-NEXT:    st %s3, 248(, %s11)
448; CHECK-NEXT:    st %s2, 240(, %s11)
449; CHECK-NEXT:    lea %s0, __atomic_compare_exchange@lo
450; CHECK-NEXT:    and %s0, %s0, (32)0
451; CHECK-NEXT:    lea.sl %s12, __atomic_compare_exchange@hi(, %s0)
452; CHECK-NEXT:    lea %s3, 240(, %s11)
453; CHECK-NEXT:    or %s0, 16, (0)1
454; CHECK-NEXT:    or %s4, 0, (0)1
455; CHECK-NEXT:    or %s5, 0, (0)1
456; CHECK-NEXT:    or %s2, 0, %s6
457; CHECK-NEXT:    bsic %s10, (, %s12)
458; CHECK-NEXT:    or %s1, 0, (0)1
459; CHECK-NEXT:    or %s11, 0, %s9
460; CHECK-NEXT:    ld %s10, 8(, %s11)
461; CHECK-NEXT:    ld %s9, (, %s11)
462; CHECK-NEXT:    b.l.t (, %s10)
463bb:
464  %i = alloca i128, align 16
465  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %i)
466  store i128 %arg2, ptr %i, align 16, !tbaa !0
467  %i6 = call zeroext i1 @__atomic_compare_exchange(i64 16, ptr nonnull %arg, ptr nonnull %arg1, ptr nonnull %i, i32 signext 0, i32 signext 0)
468  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %i)
469  %i7 = zext i1 %i6 to i128
470  ret i128 %i7
471}
472
473; Function Attrs: nounwind mustprogress
474define i128 @_Z28atomic_cmp_swap_relaxed_u128RNSt3__16atomicIoEERoo(ptr nonnull align 16 dereferenceable(16) %arg, ptr nonnull align 16 dereferenceable(16) %arg1, i128 %arg2) {
475; CHECK-LABEL: _Z28atomic_cmp_swap_relaxed_u128RNSt3__16atomicIoEERoo:
476; CHECK:       # %bb.0: # %bb
477; CHECK-NEXT:    st %s9, (, %s11)
478; CHECK-NEXT:    st %s10, 8(, %s11)
479; CHECK-NEXT:    or %s9, 0, %s11
480; CHECK-NEXT:    lea %s11, -256(, %s11)
481; CHECK-NEXT:    brge.l.t %s11, %s8, .LBB10_2
482; CHECK-NEXT:  # %bb.1: # %bb
483; CHECK-NEXT:    ld %s61, 24(, %s14)
484; CHECK-NEXT:    or %s62, 0, %s0
485; CHECK-NEXT:    lea %s63, 315
486; CHECK-NEXT:    shm.l %s63, (%s61)
487; CHECK-NEXT:    shm.l %s8, 8(%s61)
488; CHECK-NEXT:    shm.l %s11, 16(%s61)
489; CHECK-NEXT:    monc
490; CHECK-NEXT:    or %s0, 0, %s62
491; CHECK-NEXT:  .LBB10_2: # %bb
492; CHECK-NEXT:    or %s6, 0, %s1
493; CHECK-NEXT:    or %s1, 0, %s0
494; CHECK-NEXT:    st %s3, 248(, %s11)
495; CHECK-NEXT:    st %s2, 240(, %s11)
496; CHECK-NEXT:    lea %s0, __atomic_compare_exchange@lo
497; CHECK-NEXT:    and %s0, %s0, (32)0
498; CHECK-NEXT:    lea.sl %s12, __atomic_compare_exchange@hi(, %s0)
499; CHECK-NEXT:    lea %s3, 240(, %s11)
500; CHECK-NEXT:    or %s0, 16, (0)1
501; CHECK-NEXT:    or %s4, 0, (0)1
502; CHECK-NEXT:    or %s5, 0, (0)1
503; CHECK-NEXT:    or %s2, 0, %s6
504; CHECK-NEXT:    bsic %s10, (, %s12)
505; CHECK-NEXT:    or %s1, 0, (0)1
506; CHECK-NEXT:    or %s11, 0, %s9
507; CHECK-NEXT:    ld %s10, 8(, %s11)
508; CHECK-NEXT:    ld %s9, (, %s11)
509; CHECK-NEXT:    b.l.t (, %s10)
510bb:
511  %i = alloca i128, align 16
512  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %i)
513  store i128 %arg2, ptr %i, align 16, !tbaa !0
514  %i6 = call zeroext i1 @__atomic_compare_exchange(i64 16, ptr nonnull %arg, ptr nonnull %arg1, ptr nonnull %i, i32 signext 0, i32 signext 0)
515  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %i)
516  %i7 = zext i1 %i6 to i128
517  ret i128 %i7
518}
519
520; Function Attrs: nofree norecurse nounwind mustprogress
521define zeroext i1 @_Z26atomic_cmp_swap_acquire_i1RNSt3__16atomicIbEERbb(ptr nocapture nonnull align 1 dereferenceable(1) %arg, ptr nocapture nonnull align 1 dereferenceable(1) %arg1, i1 zeroext %arg2) {
522; CHECK-LABEL: _Z26atomic_cmp_swap_acquire_i1RNSt3__16atomicIbEERbb:
523; CHECK:       # %bb.0: # %bb
524; CHECK-NEXT:    ld1b.zx %s4, (, %s1)
525; CHECK-NEXT:    and %s3, -4, %s0
526; CHECK-NEXT:    and %s0, 3, %s0
527; CHECK-NEXT:    sla.w.sx %s0, %s0, 3
528; CHECK-NEXT:    ldl.sx %s5, (, %s3)
529; CHECK-NEXT:    sla.w.sx %s6, (56)0, %s0
530; CHECK-NEXT:    sla.w.sx %s2, %s2, %s0
531; CHECK-NEXT:    sla.w.sx %s4, %s4, %s0
532; CHECK-NEXT:    nnd %s5, %s6, %s5
533; CHECK-NEXT:    and %s5, %s5, (32)0
534; CHECK-NEXT:    or %s2, %s5, %s2
535; CHECK-NEXT:    or %s4, %s5, %s4
536; CHECK-NEXT:    cas.w %s2, (%s3), %s4
537; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s4
538; CHECK-NEXT:    or %s3, 0, (0)1
539; CHECK-NEXT:    cmov.w.eq %s3, (63)0, %s4
540; CHECK-NEXT:    fencem 2
541; CHECK-NEXT:    brne.w 0, %s3, .LBB11_2
542; CHECK-NEXT:  # %bb.1: # %bb7
543; CHECK-NEXT:    and %s2, %s2, (32)0
544; CHECK-NEXT:    srl %s0, %s2, %s0
545; CHECK-NEXT:    st1b %s0, (, %s1)
546; CHECK-NEXT:  .LBB11_2: # %bb9
547; CHECK-NEXT:    adds.w.zx %s0, %s3, (0)1
548; CHECK-NEXT:    b.l.t (, %s10)
549bb:
550  %i = zext i1 %arg2 to i8
551  %i4 = load i8, ptr %arg1, align 1
552  %i5 = cmpxchg weak ptr %arg, i8 %i4, i8 %i acquire acquire, align 1
553  %i6 = extractvalue { i8, i1 } %i5, 1
554  br i1 %i6, label %bb9, label %bb7
555
556bb7:                                              ; preds = %bb
557  %i8 = extractvalue { i8, i1 } %i5, 0
558  store i8 %i8, ptr %arg1, align 1
559  br label %bb9
560
561bb9:                                              ; preds = %bb7, %bb
562  ret i1 %i6
563}
564
565; Function Attrs: nofree norecurse nounwind mustprogress
566define signext i8 @_Z26atomic_cmp_swap_acquire_i8RNSt3__16atomicIcEERcc(ptr nocapture nonnull align 1 dereferenceable(1) %arg, ptr nocapture nonnull align 1 dereferenceable(1) %arg1, i8 signext %arg2) {
567; CHECK-LABEL: _Z26atomic_cmp_swap_acquire_i8RNSt3__16atomicIcEERcc:
568; CHECK:       # %bb.0: # %bb
569; CHECK-NEXT:    ld1b.zx %s4, (, %s1)
570; CHECK-NEXT:    and %s3, -4, %s0
571; CHECK-NEXT:    and %s0, 3, %s0
572; CHECK-NEXT:    sla.w.sx %s0, %s0, 3
573; CHECK-NEXT:    sla.w.sx %s5, (56)0, %s0
574; CHECK-NEXT:    ldl.sx %s6, (, %s3)
575; CHECK-NEXT:    and %s2, %s2, (56)0
576; CHECK-NEXT:    sla.w.sx %s2, %s2, %s0
577; CHECK-NEXT:    sla.w.sx %s4, %s4, %s0
578; CHECK-NEXT:    nnd %s5, %s5, %s6
579; CHECK-NEXT:    and %s5, %s5, (32)0
580; CHECK-NEXT:    or %s2, %s5, %s2
581; CHECK-NEXT:    or %s4, %s5, %s4
582; CHECK-NEXT:    cas.w %s2, (%s3), %s4
583; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s4
584; CHECK-NEXT:    or %s3, 0, (0)1
585; CHECK-NEXT:    cmov.w.eq %s3, (63)0, %s4
586; CHECK-NEXT:    fencem 2
587; CHECK-NEXT:    brne.w 0, %s3, .LBB12_2
588; CHECK-NEXT:  # %bb.1: # %bb6
589; CHECK-NEXT:    and %s2, %s2, (32)0
590; CHECK-NEXT:    srl %s0, %s2, %s0
591; CHECK-NEXT:    st1b %s0, (, %s1)
592; CHECK-NEXT:  .LBB12_2: # %bb8
593; CHECK-NEXT:    adds.w.zx %s0, %s3, (0)1
594; CHECK-NEXT:    b.l.t (, %s10)
595bb:
596  %i3 = load i8, ptr %arg1, align 1
597  %i4 = cmpxchg weak ptr %arg, i8 %i3, i8 %arg2 acquire acquire, align 1
598  %i5 = extractvalue { i8, i1 } %i4, 1
599  br i1 %i5, label %bb8, label %bb6
600
601bb6:                                              ; preds = %bb
602  %i7 = extractvalue { i8, i1 } %i4, 0
603  store i8 %i7, ptr %arg1, align 1
604  br label %bb8
605
606bb8:                                              ; preds = %bb6, %bb
607  %i9 = zext i1 %i5 to i8
608  ret i8 %i9
609}
610
611; Function Attrs: nofree norecurse nounwind mustprogress
612define zeroext i8 @_Z26atomic_cmp_swap_acquire_u8RNSt3__16atomicIhEERhh(ptr nocapture nonnull align 1 dereferenceable(1) %arg, ptr nocapture nonnull align 1 dereferenceable(1) %arg1, i8 zeroext %arg2) {
613; CHECK-LABEL: _Z26atomic_cmp_swap_acquire_u8RNSt3__16atomicIhEERhh:
614; CHECK:       # %bb.0: # %bb
615; CHECK-NEXT:    ld1b.zx %s4, (, %s1)
616; CHECK-NEXT:    and %s3, -4, %s0
617; CHECK-NEXT:    and %s0, 3, %s0
618; CHECK-NEXT:    sla.w.sx %s0, %s0, 3
619; CHECK-NEXT:    ldl.sx %s5, (, %s3)
620; CHECK-NEXT:    sla.w.sx %s6, (56)0, %s0
621; CHECK-NEXT:    sla.w.sx %s2, %s2, %s0
622; CHECK-NEXT:    sla.w.sx %s4, %s4, %s0
623; CHECK-NEXT:    nnd %s5, %s6, %s5
624; CHECK-NEXT:    and %s5, %s5, (32)0
625; CHECK-NEXT:    or %s2, %s5, %s2
626; CHECK-NEXT:    or %s4, %s5, %s4
627; CHECK-NEXT:    cas.w %s2, (%s3), %s4
628; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s4
629; CHECK-NEXT:    or %s3, 0, (0)1
630; CHECK-NEXT:    cmov.w.eq %s3, (63)0, %s4
631; CHECK-NEXT:    fencem 2
632; CHECK-NEXT:    brne.w 0, %s3, .LBB13_2
633; CHECK-NEXT:  # %bb.1: # %bb6
634; CHECK-NEXT:    and %s2, %s2, (32)0
635; CHECK-NEXT:    srl %s0, %s2, %s0
636; CHECK-NEXT:    st1b %s0, (, %s1)
637; CHECK-NEXT:  .LBB13_2: # %bb8
638; CHECK-NEXT:    adds.w.zx %s0, %s3, (0)1
639; CHECK-NEXT:    b.l.t (, %s10)
640bb:
641  %i3 = load i8, ptr %arg1, align 1
642  %i4 = cmpxchg weak ptr %arg, i8 %i3, i8 %arg2 acquire acquire, align 1
643  %i5 = extractvalue { i8, i1 } %i4, 1
644  br i1 %i5, label %bb8, label %bb6
645
646bb6:                                              ; preds = %bb
647  %i7 = extractvalue { i8, i1 } %i4, 0
648  store i8 %i7, ptr %arg1, align 1
649  br label %bb8
650
651bb8:                                              ; preds = %bb6, %bb
652  %i9 = zext i1 %i5 to i8
653  ret i8 %i9
654}
655
656; Function Attrs: nofree norecurse nounwind mustprogress
657define signext i16 @_Z27atomic_cmp_swap_acquire_i16RNSt3__16atomicIsEERss(ptr nocapture nonnull align 2 dereferenceable(2) %arg, ptr nocapture nonnull align 2 dereferenceable(2) %arg1, i16 signext %arg2) {
658; CHECK-LABEL: _Z27atomic_cmp_swap_acquire_i16RNSt3__16atomicIsEERss:
659; CHECK:       # %bb.0: # %bb
660; CHECK-NEXT:    ld2b.zx %s4, (, %s1)
661; CHECK-NEXT:    and %s3, -4, %s0
662; CHECK-NEXT:    and %s0, 3, %s0
663; CHECK-NEXT:    sla.w.sx %s0, %s0, 3
664; CHECK-NEXT:    sla.w.sx %s5, (48)0, %s0
665; CHECK-NEXT:    ldl.sx %s6, (, %s3)
666; CHECK-NEXT:    and %s2, %s2, (48)0
667; CHECK-NEXT:    sla.w.sx %s2, %s2, %s0
668; CHECK-NEXT:    sla.w.sx %s4, %s4, %s0
669; CHECK-NEXT:    nnd %s5, %s5, %s6
670; CHECK-NEXT:    and %s5, %s5, (32)0
671; CHECK-NEXT:    or %s2, %s5, %s2
672; CHECK-NEXT:    or %s4, %s5, %s4
673; CHECK-NEXT:    cas.w %s2, (%s3), %s4
674; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s4
675; CHECK-NEXT:    or %s3, 0, (0)1
676; CHECK-NEXT:    cmov.w.eq %s3, (63)0, %s4
677; CHECK-NEXT:    fencem 2
678; CHECK-NEXT:    brne.w 0, %s3, .LBB14_2
679; CHECK-NEXT:  # %bb.1: # %bb6
680; CHECK-NEXT:    and %s2, %s2, (32)0
681; CHECK-NEXT:    srl %s0, %s2, %s0
682; CHECK-NEXT:    st2b %s0, (, %s1)
683; CHECK-NEXT:  .LBB14_2: # %bb8
684; CHECK-NEXT:    adds.w.zx %s0, %s3, (0)1
685; CHECK-NEXT:    b.l.t (, %s10)
686bb:
687  %i3 = load i16, ptr %arg1, align 2
688  %i4 = cmpxchg weak ptr %arg, i16 %i3, i16 %arg2 acquire acquire, align 2
689  %i5 = extractvalue { i16, i1 } %i4, 1
690  br i1 %i5, label %bb8, label %bb6
691
692bb6:                                              ; preds = %bb
693  %i7 = extractvalue { i16, i1 } %i4, 0
694  store i16 %i7, ptr %arg1, align 2
695  br label %bb8
696
697bb8:                                              ; preds = %bb6, %bb
698  %i9 = zext i1 %i5 to i16
699  ret i16 %i9
700}
701
702; Function Attrs: nofree norecurse nounwind mustprogress
703define zeroext i16 @_Z27atomic_cmp_swap_acquire_u16RNSt3__16atomicItEERtt(ptr nocapture nonnull align 2 dereferenceable(2) %arg, ptr nocapture nonnull align 2 dereferenceable(2) %arg1, i16 zeroext %arg2) {
704; CHECK-LABEL: _Z27atomic_cmp_swap_acquire_u16RNSt3__16atomicItEERtt:
705; CHECK:       # %bb.0: # %bb
706; CHECK-NEXT:    ld2b.zx %s4, (, %s1)
707; CHECK-NEXT:    and %s3, -4, %s0
708; CHECK-NEXT:    and %s0, 3, %s0
709; CHECK-NEXT:    sla.w.sx %s0, %s0, 3
710; CHECK-NEXT:    ldl.sx %s5, (, %s3)
711; CHECK-NEXT:    sla.w.sx %s6, (48)0, %s0
712; CHECK-NEXT:    sla.w.sx %s2, %s2, %s0
713; CHECK-NEXT:    sla.w.sx %s4, %s4, %s0
714; CHECK-NEXT:    nnd %s5, %s6, %s5
715; CHECK-NEXT:    and %s5, %s5, (32)0
716; CHECK-NEXT:    or %s2, %s5, %s2
717; CHECK-NEXT:    or %s4, %s5, %s4
718; CHECK-NEXT:    cas.w %s2, (%s3), %s4
719; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s4
720; CHECK-NEXT:    or %s3, 0, (0)1
721; CHECK-NEXT:    cmov.w.eq %s3, (63)0, %s4
722; CHECK-NEXT:    fencem 2
723; CHECK-NEXT:    brne.w 0, %s3, .LBB15_2
724; CHECK-NEXT:  # %bb.1: # %bb6
725; CHECK-NEXT:    and %s2, %s2, (32)0
726; CHECK-NEXT:    srl %s0, %s2, %s0
727; CHECK-NEXT:    st2b %s0, (, %s1)
728; CHECK-NEXT:  .LBB15_2: # %bb8
729; CHECK-NEXT:    adds.w.zx %s0, %s3, (0)1
730; CHECK-NEXT:    b.l.t (, %s10)
731bb:
732  %i3 = load i16, ptr %arg1, align 2
733  %i4 = cmpxchg weak ptr %arg, i16 %i3, i16 %arg2 acquire acquire, align 2
734  %i5 = extractvalue { i16, i1 } %i4, 1
735  br i1 %i5, label %bb8, label %bb6
736
737bb6:                                              ; preds = %bb
738  %i7 = extractvalue { i16, i1 } %i4, 0
739  store i16 %i7, ptr %arg1, align 2
740  br label %bb8
741
742bb8:                                              ; preds = %bb6, %bb
743  %i9 = zext i1 %i5 to i16
744  ret i16 %i9
745}
746
747; Function Attrs: nofree norecurse nounwind mustprogress
748define signext i32 @_Z27atomic_cmp_swap_acquire_i32RNSt3__16atomicIiEERii(ptr nocapture nonnull align 4 dereferenceable(4) %arg, ptr nocapture nonnull align 4 dereferenceable(4) %arg1, i32 signext %arg2) {
749; CHECK-LABEL: _Z27atomic_cmp_swap_acquire_i32RNSt3__16atomicIiEERii:
750; CHECK:       # %bb.0: # %bb
751; CHECK-NEXT:    ldl.sx %s3, (, %s1)
752; CHECK-NEXT:    cas.w %s2, (%s0), %s3
753; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s3
754; CHECK-NEXT:    or %s0, 0, (0)1
755; CHECK-NEXT:    cmov.w.eq %s0, (63)0, %s4
756; CHECK-NEXT:    fencem 2
757; CHECK-NEXT:    breq.w %s2, %s3, .LBB16_2
758; CHECK-NEXT:  # %bb.1: # %bb6
759; CHECK-NEXT:    stl %s2, (, %s1)
760; CHECK-NEXT:  .LBB16_2: # %bb8
761; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
762; CHECK-NEXT:    b.l.t (, %s10)
763bb:
764  %i3 = load i32, ptr %arg1, align 4
765  %i4 = cmpxchg weak ptr %arg, i32 %i3, i32 %arg2 acquire acquire, align 4
766  %i5 = extractvalue { i32, i1 } %i4, 1
767  br i1 %i5, label %bb8, label %bb6
768
769bb6:                                              ; preds = %bb
770  %i7 = extractvalue { i32, i1 } %i4, 0
771  store i32 %i7, ptr %arg1, align 4
772  br label %bb8
773
774bb8:                                              ; preds = %bb6, %bb
775  %i9 = zext i1 %i5 to i32
776  ret i32 %i9
777}
778
779; Function Attrs: nofree norecurse nounwind mustprogress
780define zeroext i32 @_Z27atomic_cmp_swap_acquire_u32RNSt3__16atomicIjEERjj(ptr nocapture nonnull align 4 dereferenceable(4) %arg, ptr nocapture nonnull align 4 dereferenceable(4) %arg1, i32 zeroext %arg2) {
781; CHECK-LABEL: _Z27atomic_cmp_swap_acquire_u32RNSt3__16atomicIjEERjj:
782; CHECK:       # %bb.0: # %bb
783; CHECK-NEXT:    ldl.sx %s3, (, %s1)
784; CHECK-NEXT:    cas.w %s2, (%s0), %s3
785; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s3
786; CHECK-NEXT:    or %s0, 0, (0)1
787; CHECK-NEXT:    cmov.w.eq %s0, (63)0, %s4
788; CHECK-NEXT:    fencem 2
789; CHECK-NEXT:    breq.w %s2, %s3, .LBB17_2
790; CHECK-NEXT:  # %bb.1: # %bb6
791; CHECK-NEXT:    stl %s2, (, %s1)
792; CHECK-NEXT:  .LBB17_2: # %bb8
793; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
794; CHECK-NEXT:    b.l.t (, %s10)
795bb:
796  %i3 = load i32, ptr %arg1, align 4
797  %i4 = cmpxchg weak ptr %arg, i32 %i3, i32 %arg2 acquire acquire, align 4
798  %i5 = extractvalue { i32, i1 } %i4, 1
799  br i1 %i5, label %bb8, label %bb6
800
801bb6:                                              ; preds = %bb
802  %i7 = extractvalue { i32, i1 } %i4, 0
803  store i32 %i7, ptr %arg1, align 4
804  br label %bb8
805
806bb8:                                              ; preds = %bb6, %bb
807  %i9 = zext i1 %i5 to i32
808  ret i32 %i9
809}
810
811; Function Attrs: nofree norecurse nounwind mustprogress
812define i64 @_Z27atomic_cmp_swap_acquire_i64RNSt3__16atomicIlEERll(ptr nocapture nonnull align 8 dereferenceable(8) %arg, ptr nocapture nonnull align 8 dereferenceable(8) %arg1, i64 %arg2) {
813; CHECK-LABEL: _Z27atomic_cmp_swap_acquire_i64RNSt3__16atomicIlEERll:
814; CHECK:       # %bb.0: # %bb
815; CHECK-NEXT:    ld %s3, (, %s1)
816; CHECK-NEXT:    cas.l %s2, (%s0), %s3
817; CHECK-NEXT:    cmps.l %s4, %s2, %s3
818; CHECK-NEXT:    or %s0, 0, (0)1
819; CHECK-NEXT:    cmov.l.eq %s0, (63)0, %s4
820; CHECK-NEXT:    fencem 2
821; CHECK-NEXT:    breq.l %s2, %s3, .LBB18_2
822; CHECK-NEXT:  # %bb.1: # %bb6
823; CHECK-NEXT:    st %s2, (, %s1)
824; CHECK-NEXT:  .LBB18_2: # %bb8
825; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
826; CHECK-NEXT:    b.l.t (, %s10)
827bb:
828  %i3 = load i64, ptr %arg1, align 8
829  %i4 = cmpxchg weak ptr %arg, i64 %i3, i64 %arg2 acquire acquire, align 8
830  %i5 = extractvalue { i64, i1 } %i4, 1
831  br i1 %i5, label %bb8, label %bb6
832
833bb6:                                              ; preds = %bb
834  %i7 = extractvalue { i64, i1 } %i4, 0
835  store i64 %i7, ptr %arg1, align 8
836  br label %bb8
837
838bb8:                                              ; preds = %bb6, %bb
839  %i9 = zext i1 %i5 to i64
840  ret i64 %i9
841}
842
843; Function Attrs: nofree norecurse nounwind mustprogress
844define i64 @_Z27atomic_cmp_swap_acquire_u64RNSt3__16atomicImEERmm(ptr nocapture nonnull align 8 dereferenceable(8) %arg, ptr nocapture nonnull align 8 dereferenceable(8) %arg1, i64 %arg2) {
845; CHECK-LABEL: _Z27atomic_cmp_swap_acquire_u64RNSt3__16atomicImEERmm:
846; CHECK:       # %bb.0: # %bb
847; CHECK-NEXT:    ld %s3, (, %s1)
848; CHECK-NEXT:    cas.l %s2, (%s0), %s3
849; CHECK-NEXT:    cmps.l %s4, %s2, %s3
850; CHECK-NEXT:    or %s0, 0, (0)1
851; CHECK-NEXT:    cmov.l.eq %s0, (63)0, %s4
852; CHECK-NEXT:    fencem 2
853; CHECK-NEXT:    breq.l %s2, %s3, .LBB19_2
854; CHECK-NEXT:  # %bb.1: # %bb6
855; CHECK-NEXT:    st %s2, (, %s1)
856; CHECK-NEXT:  .LBB19_2: # %bb8
857; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
858; CHECK-NEXT:    b.l.t (, %s10)
859bb:
860  %i3 = load i64, ptr %arg1, align 8
861  %i4 = cmpxchg weak ptr %arg, i64 %i3, i64 %arg2 acquire acquire, align 8
862  %i5 = extractvalue { i64, i1 } %i4, 1
863  br i1 %i5, label %bb8, label %bb6
864
865bb6:                                              ; preds = %bb
866  %i7 = extractvalue { i64, i1 } %i4, 0
867  store i64 %i7, ptr %arg1, align 8
868  br label %bb8
869
870bb8:                                              ; preds = %bb6, %bb
871  %i9 = zext i1 %i5 to i64
872  ret i64 %i9
873}
874
875; Function Attrs: nounwind mustprogress
876define i128 @_Z28atomic_cmp_swap_acquire_i128RNSt3__16atomicInEERnn(ptr nonnull align 16 dereferenceable(16) %arg, ptr nonnull align 16 dereferenceable(16) %arg1, i128 %arg2) {
877; CHECK-LABEL: _Z28atomic_cmp_swap_acquire_i128RNSt3__16atomicInEERnn:
878; CHECK:       # %bb.0: # %bb
879; CHECK-NEXT:    st %s9, (, %s11)
880; CHECK-NEXT:    st %s10, 8(, %s11)
881; CHECK-NEXT:    or %s9, 0, %s11
882; CHECK-NEXT:    lea %s11, -256(, %s11)
883; CHECK-NEXT:    brge.l.t %s11, %s8, .LBB20_2
884; CHECK-NEXT:  # %bb.1: # %bb
885; CHECK-NEXT:    ld %s61, 24(, %s14)
886; CHECK-NEXT:    or %s62, 0, %s0
887; CHECK-NEXT:    lea %s63, 315
888; CHECK-NEXT:    shm.l %s63, (%s61)
889; CHECK-NEXT:    shm.l %s8, 8(%s61)
890; CHECK-NEXT:    shm.l %s11, 16(%s61)
891; CHECK-NEXT:    monc
892; CHECK-NEXT:    or %s0, 0, %s62
893; CHECK-NEXT:  .LBB20_2: # %bb
894; CHECK-NEXT:    or %s6, 0, %s1
895; CHECK-NEXT:    or %s1, 0, %s0
896; CHECK-NEXT:    st %s3, 248(, %s11)
897; CHECK-NEXT:    st %s2, 240(, %s11)
898; CHECK-NEXT:    lea %s0, __atomic_compare_exchange@lo
899; CHECK-NEXT:    and %s0, %s0, (32)0
900; CHECK-NEXT:    lea.sl %s12, __atomic_compare_exchange@hi(, %s0)
901; CHECK-NEXT:    lea %s3, 240(, %s11)
902; CHECK-NEXT:    or %s0, 16, (0)1
903; CHECK-NEXT:    or %s4, 2, (0)1
904; CHECK-NEXT:    or %s5, 2, (0)1
905; CHECK-NEXT:    or %s2, 0, %s6
906; CHECK-NEXT:    bsic %s10, (, %s12)
907; CHECK-NEXT:    or %s1, 0, (0)1
908; CHECK-NEXT:    or %s11, 0, %s9
909; CHECK-NEXT:    ld %s10, 8(, %s11)
910; CHECK-NEXT:    ld %s9, (, %s11)
911; CHECK-NEXT:    b.l.t (, %s10)
912bb:
913  %i = alloca i128, align 16
914  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %i)
915  store i128 %arg2, ptr %i, align 16, !tbaa !0
916  %i6 = call zeroext i1 @__atomic_compare_exchange(i64 16, ptr nonnull %arg, ptr nonnull %arg1, ptr nonnull %i, i32 signext 2, i32 signext 2)
917  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %i)
918  %i7 = zext i1 %i6 to i128
919  ret i128 %i7
920}
921
922; Function Attrs: nounwind mustprogress
923define i128 @_Z28atomic_cmp_swap_acquire_u128RNSt3__16atomicIoEERoo(ptr nonnull align 16 dereferenceable(16) %arg, ptr nonnull align 16 dereferenceable(16) %arg1, i128 %arg2) {
924; CHECK-LABEL: _Z28atomic_cmp_swap_acquire_u128RNSt3__16atomicIoEERoo:
925; CHECK:       # %bb.0: # %bb
926; CHECK-NEXT:    st %s9, (, %s11)
927; CHECK-NEXT:    st %s10, 8(, %s11)
928; CHECK-NEXT:    or %s9, 0, %s11
929; CHECK-NEXT:    lea %s11, -256(, %s11)
930; CHECK-NEXT:    brge.l.t %s11, %s8, .LBB21_2
931; CHECK-NEXT:  # %bb.1: # %bb
932; CHECK-NEXT:    ld %s61, 24(, %s14)
933; CHECK-NEXT:    or %s62, 0, %s0
934; CHECK-NEXT:    lea %s63, 315
935; CHECK-NEXT:    shm.l %s63, (%s61)
936; CHECK-NEXT:    shm.l %s8, 8(%s61)
937; CHECK-NEXT:    shm.l %s11, 16(%s61)
938; CHECK-NEXT:    monc
939; CHECK-NEXT:    or %s0, 0, %s62
940; CHECK-NEXT:  .LBB21_2: # %bb
941; CHECK-NEXT:    or %s6, 0, %s1
942; CHECK-NEXT:    or %s1, 0, %s0
943; CHECK-NEXT:    st %s3, 248(, %s11)
944; CHECK-NEXT:    st %s2, 240(, %s11)
945; CHECK-NEXT:    lea %s0, __atomic_compare_exchange@lo
946; CHECK-NEXT:    and %s0, %s0, (32)0
947; CHECK-NEXT:    lea.sl %s12, __atomic_compare_exchange@hi(, %s0)
948; CHECK-NEXT:    lea %s3, 240(, %s11)
949; CHECK-NEXT:    or %s0, 16, (0)1
950; CHECK-NEXT:    or %s4, 2, (0)1
951; CHECK-NEXT:    or %s5, 2, (0)1
952; CHECK-NEXT:    or %s2, 0, %s6
953; CHECK-NEXT:    bsic %s10, (, %s12)
954; CHECK-NEXT:    or %s1, 0, (0)1
955; CHECK-NEXT:    or %s11, 0, %s9
956; CHECK-NEXT:    ld %s10, 8(, %s11)
957; CHECK-NEXT:    ld %s9, (, %s11)
958; CHECK-NEXT:    b.l.t (, %s10)
959bb:
960  %i = alloca i128, align 16
961  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %i)
962  store i128 %arg2, ptr %i, align 16, !tbaa !0
963  %i6 = call zeroext i1 @__atomic_compare_exchange(i64 16, ptr nonnull %arg, ptr nonnull %arg1, ptr nonnull %i, i32 signext 2, i32 signext 2)
964  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %i)
965  %i7 = zext i1 %i6 to i128
966  ret i128 %i7
967}
968
969; Function Attrs: nofree norecurse nounwind mustprogress
970define zeroext i1 @_Z26atomic_cmp_swap_seq_cst_i1RNSt3__16atomicIbEERbb(ptr nocapture nonnull align 1 dereferenceable(1) %arg, ptr nocapture nonnull align 1 dereferenceable(1) %arg1, i1 zeroext %arg2) {
971; CHECK-LABEL: _Z26atomic_cmp_swap_seq_cst_i1RNSt3__16atomicIbEERbb:
972; CHECK:       # %bb.0: # %bb
973; CHECK-NEXT:    ld1b.zx %s4, (, %s1)
974; CHECK-NEXT:    fencem 3
975; CHECK-NEXT:    and %s3, -4, %s0
976; CHECK-NEXT:    and %s0, 3, %s0
977; CHECK-NEXT:    sla.w.sx %s0, %s0, 3
978; CHECK-NEXT:    ldl.sx %s5, (, %s3)
979; CHECK-NEXT:    sla.w.sx %s6, (56)0, %s0
980; CHECK-NEXT:    sla.w.sx %s2, %s2, %s0
981; CHECK-NEXT:    sla.w.sx %s4, %s4, %s0
982; CHECK-NEXT:    nnd %s5, %s6, %s5
983; CHECK-NEXT:    and %s5, %s5, (32)0
984; CHECK-NEXT:    or %s2, %s5, %s2
985; CHECK-NEXT:    or %s4, %s5, %s4
986; CHECK-NEXT:    cas.w %s2, (%s3), %s4
987; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s4
988; CHECK-NEXT:    or %s3, 0, (0)1
989; CHECK-NEXT:    cmov.w.eq %s3, (63)0, %s4
990; CHECK-NEXT:    fencem 3
991; CHECK-NEXT:    brne.w 0, %s3, .LBB22_2
992; CHECK-NEXT:  # %bb.1: # %bb7
993; CHECK-NEXT:    and %s2, %s2, (32)0
994; CHECK-NEXT:    srl %s0, %s2, %s0
995; CHECK-NEXT:    st1b %s0, (, %s1)
996; CHECK-NEXT:  .LBB22_2: # %bb9
997; CHECK-NEXT:    adds.w.zx %s0, %s3, (0)1
998; CHECK-NEXT:    b.l.t (, %s10)
999bb:
1000  %i = zext i1 %arg2 to i8
1001  %i4 = load i8, ptr %arg1, align 1
1002  %i5 = cmpxchg weak ptr %arg, i8 %i4, i8 %i seq_cst seq_cst, align 1
1003  %i6 = extractvalue { i8, i1 } %i5, 1
1004  br i1 %i6, label %bb9, label %bb7
1005
1006bb7:                                              ; preds = %bb
1007  %i8 = extractvalue { i8, i1 } %i5, 0
1008  store i8 %i8, ptr %arg1, align 1
1009  br label %bb9
1010
1011bb9:                                              ; preds = %bb7, %bb
1012  ret i1 %i6
1013}
1014
1015; Function Attrs: nofree norecurse nounwind mustprogress
1016define signext i8 @_Z26atomic_cmp_swap_seq_cst_i8RNSt3__16atomicIcEERcc(ptr nocapture nonnull align 1 dereferenceable(1) %arg, ptr nocapture nonnull align 1 dereferenceable(1) %arg1, i8 signext %arg2) {
1017; CHECK-LABEL: _Z26atomic_cmp_swap_seq_cst_i8RNSt3__16atomicIcEERcc:
1018; CHECK:       # %bb.0: # %bb
1019; CHECK-NEXT:    ld1b.zx %s4, (, %s1)
1020; CHECK-NEXT:    fencem 3
1021; CHECK-NEXT:    and %s3, -4, %s0
1022; CHECK-NEXT:    and %s0, 3, %s0
1023; CHECK-NEXT:    sla.w.sx %s0, %s0, 3
1024; CHECK-NEXT:    sla.w.sx %s5, (56)0, %s0
1025; CHECK-NEXT:    ldl.sx %s6, (, %s3)
1026; CHECK-NEXT:    and %s2, %s2, (56)0
1027; CHECK-NEXT:    sla.w.sx %s2, %s2, %s0
1028; CHECK-NEXT:    sla.w.sx %s4, %s4, %s0
1029; CHECK-NEXT:    nnd %s5, %s5, %s6
1030; CHECK-NEXT:    and %s5, %s5, (32)0
1031; CHECK-NEXT:    or %s2, %s5, %s2
1032; CHECK-NEXT:    or %s4, %s5, %s4
1033; CHECK-NEXT:    cas.w %s2, (%s3), %s4
1034; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s4
1035; CHECK-NEXT:    or %s3, 0, (0)1
1036; CHECK-NEXT:    cmov.w.eq %s3, (63)0, %s4
1037; CHECK-NEXT:    fencem 3
1038; CHECK-NEXT:    brne.w 0, %s3, .LBB23_2
1039; CHECK-NEXT:  # %bb.1: # %bb6
1040; CHECK-NEXT:    and %s2, %s2, (32)0
1041; CHECK-NEXT:    srl %s0, %s2, %s0
1042; CHECK-NEXT:    st1b %s0, (, %s1)
1043; CHECK-NEXT:  .LBB23_2: # %bb8
1044; CHECK-NEXT:    adds.w.zx %s0, %s3, (0)1
1045; CHECK-NEXT:    b.l.t (, %s10)
1046bb:
1047  %i3 = load i8, ptr %arg1, align 1
1048  %i4 = cmpxchg weak ptr %arg, i8 %i3, i8 %arg2 seq_cst seq_cst, align 1
1049  %i5 = extractvalue { i8, i1 } %i4, 1
1050  br i1 %i5, label %bb8, label %bb6
1051
1052bb6:                                              ; preds = %bb
1053  %i7 = extractvalue { i8, i1 } %i4, 0
1054  store i8 %i7, ptr %arg1, align 1
1055  br label %bb8
1056
1057bb8:                                              ; preds = %bb6, %bb
1058  %i9 = zext i1 %i5 to i8
1059  ret i8 %i9
1060}
1061
1062; Function Attrs: nofree norecurse nounwind mustprogress
1063define zeroext i8 @_Z26atomic_cmp_swap_seq_cst_u8RNSt3__16atomicIhEERhh(ptr nocapture nonnull align 1 dereferenceable(1) %arg, ptr nocapture nonnull align 1 dereferenceable(1) %arg1, i8 zeroext %arg2) {
1064; CHECK-LABEL: _Z26atomic_cmp_swap_seq_cst_u8RNSt3__16atomicIhEERhh:
1065; CHECK:       # %bb.0: # %bb
1066; CHECK-NEXT:    ld1b.zx %s4, (, %s1)
1067; CHECK-NEXT:    fencem 3
1068; CHECK-NEXT:    and %s3, -4, %s0
1069; CHECK-NEXT:    and %s0, 3, %s0
1070; CHECK-NEXT:    sla.w.sx %s0, %s0, 3
1071; CHECK-NEXT:    ldl.sx %s5, (, %s3)
1072; CHECK-NEXT:    sla.w.sx %s6, (56)0, %s0
1073; CHECK-NEXT:    sla.w.sx %s2, %s2, %s0
1074; CHECK-NEXT:    sla.w.sx %s4, %s4, %s0
1075; CHECK-NEXT:    nnd %s5, %s6, %s5
1076; CHECK-NEXT:    and %s5, %s5, (32)0
1077; CHECK-NEXT:    or %s2, %s5, %s2
1078; CHECK-NEXT:    or %s4, %s5, %s4
1079; CHECK-NEXT:    cas.w %s2, (%s3), %s4
1080; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s4
1081; CHECK-NEXT:    or %s3, 0, (0)1
1082; CHECK-NEXT:    cmov.w.eq %s3, (63)0, %s4
1083; CHECK-NEXT:    fencem 3
1084; CHECK-NEXT:    brne.w 0, %s3, .LBB24_2
1085; CHECK-NEXT:  # %bb.1: # %bb6
1086; CHECK-NEXT:    and %s2, %s2, (32)0
1087; CHECK-NEXT:    srl %s0, %s2, %s0
1088; CHECK-NEXT:    st1b %s0, (, %s1)
1089; CHECK-NEXT:  .LBB24_2: # %bb8
1090; CHECK-NEXT:    adds.w.zx %s0, %s3, (0)1
1091; CHECK-NEXT:    b.l.t (, %s10)
1092bb:
1093  %i3 = load i8, ptr %arg1, align 1
1094  %i4 = cmpxchg weak ptr %arg, i8 %i3, i8 %arg2 seq_cst seq_cst, align 1
1095  %i5 = extractvalue { i8, i1 } %i4, 1
1096  br i1 %i5, label %bb8, label %bb6
1097
1098bb6:                                              ; preds = %bb
1099  %i7 = extractvalue { i8, i1 } %i4, 0
1100  store i8 %i7, ptr %arg1, align 1
1101  br label %bb8
1102
1103bb8:                                              ; preds = %bb6, %bb
1104  %i9 = zext i1 %i5 to i8
1105  ret i8 %i9
1106}
1107
1108; Function Attrs: nofree norecurse nounwind mustprogress
1109define signext i16 @_Z27atomic_cmp_swap_seq_cst_i16RNSt3__16atomicIsEERss(ptr nocapture nonnull align 2 dereferenceable(2) %arg, ptr nocapture nonnull align 2 dereferenceable(2) %arg1, i16 signext %arg2) {
1110; CHECK-LABEL: _Z27atomic_cmp_swap_seq_cst_i16RNSt3__16atomicIsEERss:
1111; CHECK:       # %bb.0: # %bb
1112; CHECK-NEXT:    ld2b.zx %s4, (, %s1)
1113; CHECK-NEXT:    fencem 3
1114; CHECK-NEXT:    and %s3, -4, %s0
1115; CHECK-NEXT:    and %s0, 3, %s0
1116; CHECK-NEXT:    sla.w.sx %s0, %s0, 3
1117; CHECK-NEXT:    sla.w.sx %s5, (48)0, %s0
1118; CHECK-NEXT:    ldl.sx %s6, (, %s3)
1119; CHECK-NEXT:    and %s2, %s2, (48)0
1120; CHECK-NEXT:    sla.w.sx %s2, %s2, %s0
1121; CHECK-NEXT:    sla.w.sx %s4, %s4, %s0
1122; CHECK-NEXT:    nnd %s5, %s5, %s6
1123; CHECK-NEXT:    and %s5, %s5, (32)0
1124; CHECK-NEXT:    or %s2, %s5, %s2
1125; CHECK-NEXT:    or %s4, %s5, %s4
1126; CHECK-NEXT:    cas.w %s2, (%s3), %s4
1127; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s4
1128; CHECK-NEXT:    or %s3, 0, (0)1
1129; CHECK-NEXT:    cmov.w.eq %s3, (63)0, %s4
1130; CHECK-NEXT:    fencem 3
1131; CHECK-NEXT:    brne.w 0, %s3, .LBB25_2
1132; CHECK-NEXT:  # %bb.1: # %bb6
1133; CHECK-NEXT:    and %s2, %s2, (32)0
1134; CHECK-NEXT:    srl %s0, %s2, %s0
1135; CHECK-NEXT:    st2b %s0, (, %s1)
1136; CHECK-NEXT:  .LBB25_2: # %bb8
1137; CHECK-NEXT:    adds.w.zx %s0, %s3, (0)1
1138; CHECK-NEXT:    b.l.t (, %s10)
1139bb:
1140  %i3 = load i16, ptr %arg1, align 2
1141  %i4 = cmpxchg weak ptr %arg, i16 %i3, i16 %arg2 seq_cst seq_cst, align 2
1142  %i5 = extractvalue { i16, i1 } %i4, 1
1143  br i1 %i5, label %bb8, label %bb6
1144
1145bb6:                                              ; preds = %bb
1146  %i7 = extractvalue { i16, i1 } %i4, 0
1147  store i16 %i7, ptr %arg1, align 2
1148  br label %bb8
1149
1150bb8:                                              ; preds = %bb6, %bb
1151  %i9 = zext i1 %i5 to i16
1152  ret i16 %i9
1153}
1154
1155; Function Attrs: nofree norecurse nounwind mustprogress
1156define zeroext i16 @_Z27atomic_cmp_swap_seq_cst_u16RNSt3__16atomicItEERtt(ptr nocapture nonnull align 2 dereferenceable(2) %arg, ptr nocapture nonnull align 2 dereferenceable(2) %arg1, i16 zeroext %arg2) {
1157; CHECK-LABEL: _Z27atomic_cmp_swap_seq_cst_u16RNSt3__16atomicItEERtt:
1158; CHECK:       # %bb.0: # %bb
1159; CHECK-NEXT:    ld2b.zx %s4, (, %s1)
1160; CHECK-NEXT:    fencem 3
1161; CHECK-NEXT:    and %s3, -4, %s0
1162; CHECK-NEXT:    and %s0, 3, %s0
1163; CHECK-NEXT:    sla.w.sx %s0, %s0, 3
1164; CHECK-NEXT:    ldl.sx %s5, (, %s3)
1165; CHECK-NEXT:    sla.w.sx %s6, (48)0, %s0
1166; CHECK-NEXT:    sla.w.sx %s2, %s2, %s0
1167; CHECK-NEXT:    sla.w.sx %s4, %s4, %s0
1168; CHECK-NEXT:    nnd %s5, %s6, %s5
1169; CHECK-NEXT:    and %s5, %s5, (32)0
1170; CHECK-NEXT:    or %s2, %s5, %s2
1171; CHECK-NEXT:    or %s4, %s5, %s4
1172; CHECK-NEXT:    cas.w %s2, (%s3), %s4
1173; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s4
1174; CHECK-NEXT:    or %s3, 0, (0)1
1175; CHECK-NEXT:    cmov.w.eq %s3, (63)0, %s4
1176; CHECK-NEXT:    fencem 3
1177; CHECK-NEXT:    brne.w 0, %s3, .LBB26_2
1178; CHECK-NEXT:  # %bb.1: # %bb6
1179; CHECK-NEXT:    and %s2, %s2, (32)0
1180; CHECK-NEXT:    srl %s0, %s2, %s0
1181; CHECK-NEXT:    st2b %s0, (, %s1)
1182; CHECK-NEXT:  .LBB26_2: # %bb8
1183; CHECK-NEXT:    adds.w.zx %s0, %s3, (0)1
1184; CHECK-NEXT:    b.l.t (, %s10)
1185bb:
1186  %i3 = load i16, ptr %arg1, align 2
1187  %i4 = cmpxchg weak ptr %arg, i16 %i3, i16 %arg2 seq_cst seq_cst, align 2
1188  %i5 = extractvalue { i16, i1 } %i4, 1
1189  br i1 %i5, label %bb8, label %bb6
1190
1191bb6:                                              ; preds = %bb
1192  %i7 = extractvalue { i16, i1 } %i4, 0
1193  store i16 %i7, ptr %arg1, align 2
1194  br label %bb8
1195
1196bb8:                                              ; preds = %bb6, %bb
1197  %i9 = zext i1 %i5 to i16
1198  ret i16 %i9
1199}
1200
1201; Function Attrs: nofree norecurse nounwind mustprogress
1202define signext i32 @_Z27atomic_cmp_swap_seq_cst_i32RNSt3__16atomicIiEERii(ptr nocapture nonnull align 4 dereferenceable(4) %arg, ptr nocapture nonnull align 4 dereferenceable(4) %arg1, i32 signext %arg2) {
1203; CHECK-LABEL: _Z27atomic_cmp_swap_seq_cst_i32RNSt3__16atomicIiEERii:
1204; CHECK:       # %bb.0: # %bb
1205; CHECK-NEXT:    ldl.sx %s3, (, %s1)
1206; CHECK-NEXT:    fencem 3
1207; CHECK-NEXT:    cas.w %s2, (%s0), %s3
1208; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s3
1209; CHECK-NEXT:    or %s0, 0, (0)1
1210; CHECK-NEXT:    cmov.w.eq %s0, (63)0, %s4
1211; CHECK-NEXT:    fencem 3
1212; CHECK-NEXT:    breq.w %s2, %s3, .LBB27_2
1213; CHECK-NEXT:  # %bb.1: # %bb6
1214; CHECK-NEXT:    stl %s2, (, %s1)
1215; CHECK-NEXT:  .LBB27_2: # %bb8
1216; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
1217; CHECK-NEXT:    b.l.t (, %s10)
1218bb:
1219  %i3 = load i32, ptr %arg1, align 4
1220  %i4 = cmpxchg weak ptr %arg, i32 %i3, i32 %arg2 seq_cst seq_cst, align 4
1221  %i5 = extractvalue { i32, i1 } %i4, 1
1222  br i1 %i5, label %bb8, label %bb6
1223
1224bb6:                                              ; preds = %bb
1225  %i7 = extractvalue { i32, i1 } %i4, 0
1226  store i32 %i7, ptr %arg1, align 4
1227  br label %bb8
1228
1229bb8:                                              ; preds = %bb6, %bb
1230  %i9 = zext i1 %i5 to i32
1231  ret i32 %i9
1232}
1233
1234; Function Attrs: nofree norecurse nounwind mustprogress
1235define zeroext i32 @_Z27atomic_cmp_swap_seq_cst_u32RNSt3__16atomicIjEERjj(ptr nocapture nonnull align 4 dereferenceable(4) %arg, ptr nocapture nonnull align 4 dereferenceable(4) %arg1, i32 zeroext %arg2) {
1236; CHECK-LABEL: _Z27atomic_cmp_swap_seq_cst_u32RNSt3__16atomicIjEERjj:
1237; CHECK:       # %bb.0: # %bb
1238; CHECK-NEXT:    ldl.sx %s3, (, %s1)
1239; CHECK-NEXT:    fencem 3
1240; CHECK-NEXT:    cas.w %s2, (%s0), %s3
1241; CHECK-NEXT:    cmps.w.sx %s4, %s2, %s3
1242; CHECK-NEXT:    or %s0, 0, (0)1
1243; CHECK-NEXT:    cmov.w.eq %s0, (63)0, %s4
1244; CHECK-NEXT:    fencem 3
1245; CHECK-NEXT:    breq.w %s2, %s3, .LBB28_2
1246; CHECK-NEXT:  # %bb.1: # %bb6
1247; CHECK-NEXT:    stl %s2, (, %s1)
1248; CHECK-NEXT:  .LBB28_2: # %bb8
1249; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
1250; CHECK-NEXT:    b.l.t (, %s10)
1251bb:
1252  %i3 = load i32, ptr %arg1, align 4
1253  %i4 = cmpxchg weak ptr %arg, i32 %i3, i32 %arg2 seq_cst seq_cst, align 4
1254  %i5 = extractvalue { i32, i1 } %i4, 1
1255  br i1 %i5, label %bb8, label %bb6
1256
1257bb6:                                              ; preds = %bb
1258  %i7 = extractvalue { i32, i1 } %i4, 0
1259  store i32 %i7, ptr %arg1, align 4
1260  br label %bb8
1261
1262bb8:                                              ; preds = %bb6, %bb
1263  %i9 = zext i1 %i5 to i32
1264  ret i32 %i9
1265}
1266
1267; Function Attrs: nofree norecurse nounwind mustprogress
1268define i64 @_Z27atomic_cmp_swap_seq_cst_i64RNSt3__16atomicIlEERll(ptr nocapture nonnull align 8 dereferenceable(8) %arg, ptr nocapture nonnull align 8 dereferenceable(8) %arg1, i64 %arg2) {
1269; CHECK-LABEL: _Z27atomic_cmp_swap_seq_cst_i64RNSt3__16atomicIlEERll:
1270; CHECK:       # %bb.0: # %bb
1271; CHECK-NEXT:    ld %s3, (, %s1)
1272; CHECK-NEXT:    fencem 3
1273; CHECK-NEXT:    cas.l %s2, (%s0), %s3
1274; CHECK-NEXT:    cmps.l %s4, %s2, %s3
1275; CHECK-NEXT:    or %s0, 0, (0)1
1276; CHECK-NEXT:    cmov.l.eq %s0, (63)0, %s4
1277; CHECK-NEXT:    fencem 3
1278; CHECK-NEXT:    breq.l %s2, %s3, .LBB29_2
1279; CHECK-NEXT:  # %bb.1: # %bb6
1280; CHECK-NEXT:    st %s2, (, %s1)
1281; CHECK-NEXT:  .LBB29_2: # %bb8
1282; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
1283; CHECK-NEXT:    b.l.t (, %s10)
1284bb:
1285  %i3 = load i64, ptr %arg1, align 8
1286  %i4 = cmpxchg weak ptr %arg, i64 %i3, i64 %arg2 seq_cst seq_cst, align 8
1287  %i5 = extractvalue { i64, i1 } %i4, 1
1288  br i1 %i5, label %bb8, label %bb6
1289
1290bb6:                                              ; preds = %bb
1291  %i7 = extractvalue { i64, i1 } %i4, 0
1292  store i64 %i7, ptr %arg1, align 8
1293  br label %bb8
1294
1295bb8:                                              ; preds = %bb6, %bb
1296  %i9 = zext i1 %i5 to i64
1297  ret i64 %i9
1298}
1299
1300; Function Attrs: nofree norecurse nounwind mustprogress
1301define i64 @_Z27atomic_cmp_swap_seq_cst_u64RNSt3__16atomicImEERmm(ptr nocapture nonnull align 8 dereferenceable(8) %arg, ptr nocapture nonnull align 8 dereferenceable(8) %arg1, i64 %arg2) {
1302; CHECK-LABEL: _Z27atomic_cmp_swap_seq_cst_u64RNSt3__16atomicImEERmm:
1303; CHECK:       # %bb.0: # %bb
1304; CHECK-NEXT:    ld %s3, (, %s1)
1305; CHECK-NEXT:    fencem 3
1306; CHECK-NEXT:    cas.l %s2, (%s0), %s3
1307; CHECK-NEXT:    cmps.l %s4, %s2, %s3
1308; CHECK-NEXT:    or %s0, 0, (0)1
1309; CHECK-NEXT:    cmov.l.eq %s0, (63)0, %s4
1310; CHECK-NEXT:    fencem 3
1311; CHECK-NEXT:    breq.l %s2, %s3, .LBB30_2
1312; CHECK-NEXT:  # %bb.1: # %bb6
1313; CHECK-NEXT:    st %s2, (, %s1)
1314; CHECK-NEXT:  .LBB30_2: # %bb8
1315; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
1316; CHECK-NEXT:    b.l.t (, %s10)
1317bb:
1318  %i3 = load i64, ptr %arg1, align 8
1319  %i4 = cmpxchg weak ptr %arg, i64 %i3, i64 %arg2 seq_cst seq_cst, align 8
1320  %i5 = extractvalue { i64, i1 } %i4, 1
1321  br i1 %i5, label %bb8, label %bb6
1322
1323bb6:                                              ; preds = %bb
1324  %i7 = extractvalue { i64, i1 } %i4, 0
1325  store i64 %i7, ptr %arg1, align 8
1326  br label %bb8
1327
1328bb8:                                              ; preds = %bb6, %bb
1329  %i9 = zext i1 %i5 to i64
1330  ret i64 %i9
1331}
1332
1333; Function Attrs: nounwind mustprogress
1334define i128 @_Z28atomic_cmp_swap_seq_cst_i128RNSt3__16atomicInEERnn(ptr nonnull align 16 dereferenceable(16) %arg, ptr nonnull align 16 dereferenceable(16) %arg1, i128 %arg2) {
1335; CHECK-LABEL: _Z28atomic_cmp_swap_seq_cst_i128RNSt3__16atomicInEERnn:
1336; CHECK:       # %bb.0: # %bb
1337; CHECK-NEXT:    st %s9, (, %s11)
1338; CHECK-NEXT:    st %s10, 8(, %s11)
1339; CHECK-NEXT:    or %s9, 0, %s11
1340; CHECK-NEXT:    lea %s11, -256(, %s11)
1341; CHECK-NEXT:    brge.l.t %s11, %s8, .LBB31_2
1342; CHECK-NEXT:  # %bb.1: # %bb
1343; CHECK-NEXT:    ld %s61, 24(, %s14)
1344; CHECK-NEXT:    or %s62, 0, %s0
1345; CHECK-NEXT:    lea %s63, 315
1346; CHECK-NEXT:    shm.l %s63, (%s61)
1347; CHECK-NEXT:    shm.l %s8, 8(%s61)
1348; CHECK-NEXT:    shm.l %s11, 16(%s61)
1349; CHECK-NEXT:    monc
1350; CHECK-NEXT:    or %s0, 0, %s62
1351; CHECK-NEXT:  .LBB31_2: # %bb
1352; CHECK-NEXT:    or %s6, 0, %s1
1353; CHECK-NEXT:    or %s1, 0, %s0
1354; CHECK-NEXT:    st %s3, 248(, %s11)
1355; CHECK-NEXT:    st %s2, 240(, %s11)
1356; CHECK-NEXT:    lea %s0, __atomic_compare_exchange@lo
1357; CHECK-NEXT:    and %s0, %s0, (32)0
1358; CHECK-NEXT:    lea.sl %s12, __atomic_compare_exchange@hi(, %s0)
1359; CHECK-NEXT:    lea %s3, 240(, %s11)
1360; CHECK-NEXT:    or %s0, 16, (0)1
1361; CHECK-NEXT:    or %s4, 5, (0)1
1362; CHECK-NEXT:    or %s5, 5, (0)1
1363; CHECK-NEXT:    or %s2, 0, %s6
1364; CHECK-NEXT:    bsic %s10, (, %s12)
1365; CHECK-NEXT:    or %s1, 0, (0)1
1366; CHECK-NEXT:    or %s11, 0, %s9
1367; CHECK-NEXT:    ld %s10, 8(, %s11)
1368; CHECK-NEXT:    ld %s9, (, %s11)
1369; CHECK-NEXT:    b.l.t (, %s10)
1370bb:
1371  %i = alloca i128, align 16
1372  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %i)
1373  store i128 %arg2, ptr %i, align 16, !tbaa !0
1374  %i6 = call zeroext i1 @__atomic_compare_exchange(i64 16, ptr nonnull %arg, ptr nonnull %arg1, ptr nonnull %i, i32 signext 5, i32 signext 5)
1375  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %i)
1376  %i7 = zext i1 %i6 to i128
1377  ret i128 %i7
1378}
1379
1380; Function Attrs: nounwind mustprogress
1381define i128 @_Z28atomic_cmp_swap_seq_cst_u128RNSt3__16atomicIoEERoo(ptr nonnull align 16 dereferenceable(16) %arg, ptr nonnull align 16 dereferenceable(16) %arg1, i128 %arg2) {
1382; CHECK-LABEL: _Z28atomic_cmp_swap_seq_cst_u128RNSt3__16atomicIoEERoo:
1383; CHECK:       # %bb.0: # %bb
1384; CHECK-NEXT:    st %s9, (, %s11)
1385; CHECK-NEXT:    st %s10, 8(, %s11)
1386; CHECK-NEXT:    or %s9, 0, %s11
1387; CHECK-NEXT:    lea %s11, -256(, %s11)
1388; CHECK-NEXT:    brge.l.t %s11, %s8, .LBB32_2
1389; CHECK-NEXT:  # %bb.1: # %bb
1390; CHECK-NEXT:    ld %s61, 24(, %s14)
1391; CHECK-NEXT:    or %s62, 0, %s0
1392; CHECK-NEXT:    lea %s63, 315
1393; CHECK-NEXT:    shm.l %s63, (%s61)
1394; CHECK-NEXT:    shm.l %s8, 8(%s61)
1395; CHECK-NEXT:    shm.l %s11, 16(%s61)
1396; CHECK-NEXT:    monc
1397; CHECK-NEXT:    or %s0, 0, %s62
1398; CHECK-NEXT:  .LBB32_2: # %bb
1399; CHECK-NEXT:    or %s6, 0, %s1
1400; CHECK-NEXT:    or %s1, 0, %s0
1401; CHECK-NEXT:    st %s3, 248(, %s11)
1402; CHECK-NEXT:    st %s2, 240(, %s11)
1403; CHECK-NEXT:    lea %s0, __atomic_compare_exchange@lo
1404; CHECK-NEXT:    and %s0, %s0, (32)0
1405; CHECK-NEXT:    lea.sl %s12, __atomic_compare_exchange@hi(, %s0)
1406; CHECK-NEXT:    lea %s3, 240(, %s11)
1407; CHECK-NEXT:    or %s0, 16, (0)1
1408; CHECK-NEXT:    or %s4, 5, (0)1
1409; CHECK-NEXT:    or %s5, 5, (0)1
1410; CHECK-NEXT:    or %s2, 0, %s6
1411; CHECK-NEXT:    bsic %s10, (, %s12)
1412; CHECK-NEXT:    or %s1, 0, (0)1
1413; CHECK-NEXT:    or %s11, 0, %s9
1414; CHECK-NEXT:    ld %s10, 8(, %s11)
1415; CHECK-NEXT:    ld %s9, (, %s11)
1416; CHECK-NEXT:    b.l.t (, %s10)
1417bb:
1418  %i = alloca i128, align 16
1419  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %i)
1420  store i128 %arg2, ptr %i, align 16, !tbaa !0
1421  %i6 = call zeroext i1 @__atomic_compare_exchange(i64 16, ptr nonnull %arg, ptr nonnull %arg1, ptr nonnull %i, i32 signext 5, i32 signext 5)
1422  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %i)
1423  %i7 = zext i1 %i6 to i128
1424  ret i128 %i7
1425}
1426
1427; Function Attrs: nofree nounwind mustprogress
1428define zeroext i1 @_Z30atomic_cmp_swap_relaxed_stk_i1Rbb(ptr nocapture nonnull align 1 dereferenceable(1) %arg, i1 zeroext %arg1) {
1429; CHECK-LABEL: _Z30atomic_cmp_swap_relaxed_stk_i1Rbb:
1430; CHECK:       # %bb.0: # %bb
1431; CHECK-NEXT:    adds.l %s11, -16, %s11
1432; CHECK-NEXT:    brge.l %s11, %s8, .LBB33_4
1433; CHECK-NEXT:  # %bb.3: # %bb
1434; CHECK-NEXT:    ld %s61, 24(, %s14)
1435; CHECK-NEXT:    or %s62, 0, %s0
1436; CHECK-NEXT:    lea %s63, 315
1437; CHECK-NEXT:    shm.l %s63, (%s61)
1438; CHECK-NEXT:    shm.l %s8, 8(%s61)
1439; CHECK-NEXT:    shm.l %s11, 16(%s61)
1440; CHECK-NEXT:    monc
1441; CHECK-NEXT:    or %s0, 0, %s62
1442; CHECK-NEXT:  .LBB33_4: # %bb
1443; CHECK-NEXT:    and %s1, %s1, (32)0
1444; CHECK-NEXT:    ld1b.zx %s3, (, %s0)
1445; CHECK-NEXT:    ldl.zx %s4, 8(, %s11)
1446; CHECK-NEXT:    lea %s2, 8(, %s11)
1447; CHECK-NEXT:    lea %s5, -256
1448; CHECK-NEXT:    and %s5, %s5, (32)0
1449; CHECK-NEXT:    and %s4, %s4, %s5
1450; CHECK-NEXT:    and %s4, %s4, (32)0
1451; CHECK-NEXT:    or %s1, %s4, %s1
1452; CHECK-NEXT:    or %s3, %s4, %s3
1453; CHECK-NEXT:    cas.w %s1, (%s2), %s3
1454; CHECK-NEXT:    cmps.w.sx %s3, %s1, %s3
1455; CHECK-NEXT:    or %s2, 0, (0)1
1456; CHECK-NEXT:    cmov.w.eq %s2, (63)0, %s3
1457; CHECK-NEXT:    brne.w 0, %s2, .LBB33_2
1458; CHECK-NEXT:  # %bb.1: # %bb7
1459; CHECK-NEXT:    st1b %s1, (, %s0)
1460; CHECK-NEXT:  .LBB33_2: # %bb9
1461; CHECK-NEXT:    adds.w.zx %s0, %s2, (0)1
1462; CHECK-NEXT:    adds.l %s11, 16, %s11
1463; CHECK-NEXT:    b.l.t (, %s10)
1464bb:
1465  %i = alloca %"struct.std::__1::atomic", align 8
1466  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %i)
1467  %i3 = zext i1 %arg1 to i8
1468  %i4 = load i8, ptr %arg, align 1
1469  %i5 = cmpxchg weak volatile ptr %i, i8 %i4, i8 %i3 monotonic monotonic, align 1
1470  %i6 = extractvalue { i8, i1 } %i5, 1
1471  br i1 %i6, label %bb9, label %bb7
1472
1473bb7:                                              ; preds = %bb
1474  %i8 = extractvalue { i8, i1 } %i5, 0
1475  store i8 %i8, ptr %arg, align 1
1476  br label %bb9
1477
1478bb9:                                              ; preds = %bb7, %bb
1479  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %i)
1480  ret i1 %i6
1481}
1482
1483; Function Attrs: argmemonly nofree nosync nounwind willreturn
1484declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
1485
1486; Function Attrs: argmemonly nofree nosync nounwind willreturn
1487declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
1488
1489; Function Attrs: nofree nounwind mustprogress
1490define signext i8 @_Z30atomic_cmp_swap_relaxed_stk_i8Rcc(ptr nocapture nonnull align 1 dereferenceable(1) %arg, i8 signext %arg1) {
1491; CHECK-LABEL: _Z30atomic_cmp_swap_relaxed_stk_i8Rcc:
1492; CHECK:       # %bb.0: # %bb
1493; CHECK-NEXT:    adds.l %s11, -16, %s11
1494; CHECK-NEXT:    brge.l %s11, %s8, .LBB34_4
1495; CHECK-NEXT:  # %bb.3: # %bb
1496; CHECK-NEXT:    ld %s61, 24(, %s14)
1497; CHECK-NEXT:    or %s62, 0, %s0
1498; CHECK-NEXT:    lea %s63, 315
1499; CHECK-NEXT:    shm.l %s63, (%s61)
1500; CHECK-NEXT:    shm.l %s8, 8(%s61)
1501; CHECK-NEXT:    shm.l %s11, 16(%s61)
1502; CHECK-NEXT:    monc
1503; CHECK-NEXT:    or %s0, 0, %s62
1504; CHECK-NEXT:  .LBB34_4: # %bb
1505; CHECK-NEXT:    ld1b.zx %s3, (, %s0)
1506; CHECK-NEXT:    lea %s2, 8(, %s11)
1507; CHECK-NEXT:    and %s1, %s1, (56)0
1508; CHECK-NEXT:    ldl.zx %s4, 8(, %s11)
1509; CHECK-NEXT:    and %s1, %s1, (32)0
1510; CHECK-NEXT:    lea %s5, -256
1511; CHECK-NEXT:    and %s5, %s5, (32)0
1512; CHECK-NEXT:    and %s4, %s4, %s5
1513; CHECK-NEXT:    and %s4, %s4, (32)0
1514; CHECK-NEXT:    or %s1, %s4, %s1
1515; CHECK-NEXT:    or %s3, %s4, %s3
1516; CHECK-NEXT:    cas.w %s1, (%s2), %s3
1517; CHECK-NEXT:    cmps.w.sx %s3, %s1, %s3
1518; CHECK-NEXT:    or %s2, 0, (0)1
1519; CHECK-NEXT:    cmov.w.eq %s2, (63)0, %s3
1520; CHECK-NEXT:    brne.w 0, %s2, .LBB34_2
1521; CHECK-NEXT:  # %bb.1: # %bb6
1522; CHECK-NEXT:    st1b %s1, (, %s0)
1523; CHECK-NEXT:  .LBB34_2: # %bb8
1524; CHECK-NEXT:    adds.w.zx %s0, %s2, (0)1
1525; CHECK-NEXT:    adds.l %s11, 16, %s11
1526; CHECK-NEXT:    b.l.t (, %s10)
1527bb:
1528  %i = alloca %"struct.std::__1::atomic.0", align 8
1529  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %i)
1530  %i3 = load i8, ptr %arg, align 1
1531  %i4 = cmpxchg weak volatile ptr %i, i8 %i3, i8 %arg1 monotonic monotonic, align 1
1532  %i5 = extractvalue { i8, i1 } %i4, 1
1533  br i1 %i5, label %bb8, label %bb6
1534
1535bb6:                                              ; preds = %bb
1536  %i7 = extractvalue { i8, i1 } %i4, 0
1537  store i8 %i7, ptr %arg, align 1
1538  br label %bb8
1539
1540bb8:                                              ; preds = %bb6, %bb
1541  %i9 = zext i1 %i5 to i8
1542  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %i)
1543  ret i8 %i9
1544}
1545
1546; Function Attrs: nofree nounwind mustprogress
1547define zeroext i8 @_Z30atomic_cmp_swap_relaxed_stk_u8Rhh(ptr nocapture nonnull align 1 dereferenceable(1) %arg, i8 zeroext %arg1) {
1548; CHECK-LABEL: _Z30atomic_cmp_swap_relaxed_stk_u8Rhh:
1549; CHECK:       # %bb.0: # %bb
1550; CHECK-NEXT:    adds.l %s11, -16, %s11
1551; CHECK-NEXT:    brge.l %s11, %s8, .LBB35_4
1552; CHECK-NEXT:  # %bb.3: # %bb
1553; CHECK-NEXT:    ld %s61, 24(, %s14)
1554; CHECK-NEXT:    or %s62, 0, %s0
1555; CHECK-NEXT:    lea %s63, 315
1556; CHECK-NEXT:    shm.l %s63, (%s61)
1557; CHECK-NEXT:    shm.l %s8, 8(%s61)
1558; CHECK-NEXT:    shm.l %s11, 16(%s61)
1559; CHECK-NEXT:    monc
1560; CHECK-NEXT:    or %s0, 0, %s62
1561; CHECK-NEXT:  .LBB35_4: # %bb
1562; CHECK-NEXT:    and %s1, %s1, (32)0
1563; CHECK-NEXT:    ld1b.zx %s3, (, %s0)
1564; CHECK-NEXT:    ldl.zx %s4, 8(, %s11)
1565; CHECK-NEXT:    lea %s2, 8(, %s11)
1566; CHECK-NEXT:    lea %s5, -256
1567; CHECK-NEXT:    and %s5, %s5, (32)0
1568; CHECK-NEXT:    and %s4, %s4, %s5
1569; CHECK-NEXT:    and %s4, %s4, (32)0
1570; CHECK-NEXT:    or %s1, %s4, %s1
1571; CHECK-NEXT:    or %s3, %s4, %s3
1572; CHECK-NEXT:    cas.w %s1, (%s2), %s3
1573; CHECK-NEXT:    cmps.w.sx %s3, %s1, %s3
1574; CHECK-NEXT:    or %s2, 0, (0)1
1575; CHECK-NEXT:    cmov.w.eq %s2, (63)0, %s3
1576; CHECK-NEXT:    brne.w 0, %s2, .LBB35_2
1577; CHECK-NEXT:  # %bb.1: # %bb6
1578; CHECK-NEXT:    st1b %s1, (, %s0)
1579; CHECK-NEXT:  .LBB35_2: # %bb8
1580; CHECK-NEXT:    adds.w.zx %s0, %s2, (0)1
1581; CHECK-NEXT:    adds.l %s11, 16, %s11
1582; CHECK-NEXT:    b.l.t (, %s10)
1583bb:
1584  %i = alloca %"struct.std::__1::atomic.5", align 8
1585  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %i)
1586  %i3 = load i8, ptr %arg, align 1
1587  %i4 = cmpxchg weak volatile ptr %i, i8 %i3, i8 %arg1 monotonic monotonic, align 1
1588  %i5 = extractvalue { i8, i1 } %i4, 1
1589  br i1 %i5, label %bb8, label %bb6
1590
1591bb6:                                              ; preds = %bb
1592  %i7 = extractvalue { i8, i1 } %i4, 0
1593  store i8 %i7, ptr %arg, align 1
1594  br label %bb8
1595
1596bb8:                                              ; preds = %bb6, %bb
1597  %i9 = zext i1 %i5 to i8
1598  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %i)
1599  ret i8 %i9
1600}
1601
1602; Function Attrs: nofree nounwind mustprogress
1603define signext i16 @_Z31atomic_cmp_swap_relaxed_stk_i16Rss(ptr nocapture nonnull align 2 dereferenceable(2) %arg, i16 signext %arg1) {
1604; CHECK-LABEL: _Z31atomic_cmp_swap_relaxed_stk_i16Rss:
1605; CHECK:       # %bb.0: # %bb
1606; CHECK-NEXT:    adds.l %s11, -16, %s11
1607; CHECK-NEXT:    brge.l %s11, %s8, .LBB36_4
1608; CHECK-NEXT:  # %bb.3: # %bb
1609; CHECK-NEXT:    ld %s61, 24(, %s14)
1610; CHECK-NEXT:    or %s62, 0, %s0
1611; CHECK-NEXT:    lea %s63, 315
1612; CHECK-NEXT:    shm.l %s63, (%s61)
1613; CHECK-NEXT:    shm.l %s8, 8(%s61)
1614; CHECK-NEXT:    shm.l %s11, 16(%s61)
1615; CHECK-NEXT:    monc
1616; CHECK-NEXT:    or %s0, 0, %s62
1617; CHECK-NEXT:  .LBB36_4: # %bb
1618; CHECK-NEXT:    ld2b.zx %s3, (, %s0)
1619; CHECK-NEXT:    lea %s2, 8(, %s11)
1620; CHECK-NEXT:    and %s1, %s1, (48)0
1621; CHECK-NEXT:    ldl.zx %s4, 8(, %s11)
1622; CHECK-NEXT:    and %s1, %s1, (32)0
1623; CHECK-NEXT:    lea %s5, -65536
1624; CHECK-NEXT:    and %s5, %s5, (32)0
1625; CHECK-NEXT:    and %s4, %s4, %s5
1626; CHECK-NEXT:    and %s4, %s4, (32)0
1627; CHECK-NEXT:    or %s1, %s4, %s1
1628; CHECK-NEXT:    or %s3, %s4, %s3
1629; CHECK-NEXT:    cas.w %s1, (%s2), %s3
1630; CHECK-NEXT:    cmps.w.sx %s3, %s1, %s3
1631; CHECK-NEXT:    or %s2, 0, (0)1
1632; CHECK-NEXT:    cmov.w.eq %s2, (63)0, %s3
1633; CHECK-NEXT:    brne.w 0, %s2, .LBB36_2
1634; CHECK-NEXT:  # %bb.1: # %bb7
1635; CHECK-NEXT:    st2b %s1, (, %s0)
1636; CHECK-NEXT:  .LBB36_2: # %bb9
1637; CHECK-NEXT:    adds.w.zx %s0, %s2, (0)1
1638; CHECK-NEXT:    adds.l %s11, 16, %s11
1639; CHECK-NEXT:    b.l.t (, %s10)
1640bb:
1641  %i = alloca %"struct.std::__1::atomic.10", align 8
1642  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %i)
1643  %i4 = load i16, ptr %arg, align 2
1644  %i5 = cmpxchg weak volatile ptr %i, i16 %i4, i16 %arg1 monotonic monotonic, align 2
1645  %i6 = extractvalue { i16, i1 } %i5, 1
1646  br i1 %i6, label %bb9, label %bb7
1647
1648bb7:                                              ; preds = %bb
1649  %i8 = extractvalue { i16, i1 } %i5, 0
1650  store i16 %i8, ptr %arg, align 2
1651  br label %bb9
1652
1653bb9:                                              ; preds = %bb7, %bb
1654  %i10 = zext i1 %i6 to i16
1655  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %i)
1656  ret i16 %i10
1657}
1658
1659; Function Attrs: nofree nounwind mustprogress
1660define zeroext i16 @_Z31atomic_cmp_swap_relaxed_stk_u16Rtt(ptr nocapture nonnull align 2 dereferenceable(2) %arg, i16 zeroext %arg1) {
1661; CHECK-LABEL: _Z31atomic_cmp_swap_relaxed_stk_u16Rtt:
1662; CHECK:       # %bb.0: # %bb
1663; CHECK-NEXT:    adds.l %s11, -16, %s11
1664; CHECK-NEXT:    brge.l %s11, %s8, .LBB37_4
1665; CHECK-NEXT:  # %bb.3: # %bb
1666; CHECK-NEXT:    ld %s61, 24(, %s14)
1667; CHECK-NEXT:    or %s62, 0, %s0
1668; CHECK-NEXT:    lea %s63, 315
1669; CHECK-NEXT:    shm.l %s63, (%s61)
1670; CHECK-NEXT:    shm.l %s8, 8(%s61)
1671; CHECK-NEXT:    shm.l %s11, 16(%s61)
1672; CHECK-NEXT:    monc
1673; CHECK-NEXT:    or %s0, 0, %s62
1674; CHECK-NEXT:  .LBB37_4: # %bb
1675; CHECK-NEXT:    and %s1, %s1, (32)0
1676; CHECK-NEXT:    ld2b.zx %s3, (, %s0)
1677; CHECK-NEXT:    ldl.zx %s4, 8(, %s11)
1678; CHECK-NEXT:    lea %s2, 8(, %s11)
1679; CHECK-NEXT:    lea %s5, -65536
1680; CHECK-NEXT:    and %s5, %s5, (32)0
1681; CHECK-NEXT:    and %s4, %s4, %s5
1682; CHECK-NEXT:    and %s4, %s4, (32)0
1683; CHECK-NEXT:    or %s1, %s4, %s1
1684; CHECK-NEXT:    or %s3, %s4, %s3
1685; CHECK-NEXT:    cas.w %s1, (%s2), %s3
1686; CHECK-NEXT:    cmps.w.sx %s3, %s1, %s3
1687; CHECK-NEXT:    or %s2, 0, (0)1
1688; CHECK-NEXT:    cmov.w.eq %s2, (63)0, %s3
1689; CHECK-NEXT:    brne.w 0, %s2, .LBB37_2
1690; CHECK-NEXT:  # %bb.1: # %bb7
1691; CHECK-NEXT:    st2b %s1, (, %s0)
1692; CHECK-NEXT:  .LBB37_2: # %bb9
1693; CHECK-NEXT:    adds.w.zx %s0, %s2, (0)1
1694; CHECK-NEXT:    adds.l %s11, 16, %s11
1695; CHECK-NEXT:    b.l.t (, %s10)
1696bb:
1697  %i = alloca %"struct.std::__1::atomic.15", align 8
1698  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %i)
1699  %i4 = load i16, ptr %arg, align 2
1700  %i5 = cmpxchg weak volatile ptr %i, i16 %i4, i16 %arg1 monotonic monotonic, align 2
1701  %i6 = extractvalue { i16, i1 } %i5, 1
1702  br i1 %i6, label %bb9, label %bb7
1703
1704bb7:                                              ; preds = %bb
1705  %i8 = extractvalue { i16, i1 } %i5, 0
1706  store i16 %i8, ptr %arg, align 2
1707  br label %bb9
1708
1709bb9:                                              ; preds = %bb7, %bb
1710  %i10 = zext i1 %i6 to i16
1711  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %i)
1712  ret i16 %i10
1713}
1714
1715; Function Attrs: nofree nounwind mustprogress
1716define signext i32 @_Z31atomic_cmp_swap_relaxed_stk_i32Rii(ptr nocapture nonnull align 4 dereferenceable(4) %arg, i32 signext %arg1) {
1717; CHECK-LABEL: _Z31atomic_cmp_swap_relaxed_stk_i32Rii:
1718; CHECK:       # %bb.0: # %bb
1719; CHECK-NEXT:    adds.l %s11, -16, %s11
1720; CHECK-NEXT:    brge.l %s11, %s8, .LBB38_4
1721; CHECK-NEXT:  # %bb.3: # %bb
1722; CHECK-NEXT:    ld %s61, 24(, %s14)
1723; CHECK-NEXT:    or %s62, 0, %s0
1724; CHECK-NEXT:    lea %s63, 315
1725; CHECK-NEXT:    shm.l %s63, (%s61)
1726; CHECK-NEXT:    shm.l %s8, 8(%s61)
1727; CHECK-NEXT:    shm.l %s11, 16(%s61)
1728; CHECK-NEXT:    monc
1729; CHECK-NEXT:    or %s0, 0, %s62
1730; CHECK-NEXT:  .LBB38_4: # %bb
1731; CHECK-NEXT:    ldl.sx %s3, (, %s0)
1732; CHECK-NEXT:    cas.w %s1, 8(%s11), %s3
1733; CHECK-NEXT:    cmps.w.sx %s4, %s1, %s3
1734; CHECK-NEXT:    or %s2, 0, (0)1
1735; CHECK-NEXT:    cmov.w.eq %s2, (63)0, %s4
1736; CHECK-NEXT:    breq.w %s1, %s3, .LBB38_2
1737; CHECK-NEXT:  # %bb.1: # %bb7
1738; CHECK-NEXT:    stl %s1, (, %s0)
1739; CHECK-NEXT:  .LBB38_2: # %bb9
1740; CHECK-NEXT:    adds.w.zx %s0, %s2, (0)1
1741; CHECK-NEXT:    adds.l %s11, 16, %s11
1742; CHECK-NEXT:    b.l.t (, %s10)
1743bb:
1744  %i = alloca %"struct.std::__1::atomic.20", align 8
1745  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %i)
1746  %i4 = load i32, ptr %arg, align 4
1747  %i5 = cmpxchg weak volatile ptr %i, i32 %i4, i32 %arg1 monotonic monotonic, align 4
1748  %i6 = extractvalue { i32, i1 } %i5, 1
1749  br i1 %i6, label %bb9, label %bb7
1750
1751bb7:                                              ; preds = %bb
1752  %i8 = extractvalue { i32, i1 } %i5, 0
1753  store i32 %i8, ptr %arg, align 4
1754  br label %bb9
1755
1756bb9:                                              ; preds = %bb7, %bb
1757  %i10 = zext i1 %i6 to i32
1758  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %i)
1759  ret i32 %i10
1760}
1761
1762; Function Attrs: nofree nounwind mustprogress
1763define zeroext i32 @_Z31atomic_cmp_swap_relaxed_stk_u32Rjj(ptr nocapture nonnull align 4 dereferenceable(4) %arg, i32 zeroext %arg1) {
1764; CHECK-LABEL: _Z31atomic_cmp_swap_relaxed_stk_u32Rjj:
1765; CHECK:       # %bb.0: # %bb
1766; CHECK-NEXT:    adds.l %s11, -16, %s11
1767; CHECK-NEXT:    brge.l %s11, %s8, .LBB39_4
1768; CHECK-NEXT:  # %bb.3: # %bb
1769; CHECK-NEXT:    ld %s61, 24(, %s14)
1770; CHECK-NEXT:    or %s62, 0, %s0
1771; CHECK-NEXT:    lea %s63, 315
1772; CHECK-NEXT:    shm.l %s63, (%s61)
1773; CHECK-NEXT:    shm.l %s8, 8(%s61)
1774; CHECK-NEXT:    shm.l %s11, 16(%s61)
1775; CHECK-NEXT:    monc
1776; CHECK-NEXT:    or %s0, 0, %s62
1777; CHECK-NEXT:  .LBB39_4: # %bb
1778; CHECK-NEXT:    ldl.sx %s3, (, %s0)
1779; CHECK-NEXT:    cas.w %s1, 8(%s11), %s3
1780; CHECK-NEXT:    cmps.w.sx %s4, %s1, %s3
1781; CHECK-NEXT:    or %s2, 0, (0)1
1782; CHECK-NEXT:    cmov.w.eq %s2, (63)0, %s4
1783; CHECK-NEXT:    breq.w %s1, %s3, .LBB39_2
1784; CHECK-NEXT:  # %bb.1: # %bb7
1785; CHECK-NEXT:    stl %s1, (, %s0)
1786; CHECK-NEXT:  .LBB39_2: # %bb9
1787; CHECK-NEXT:    adds.w.zx %s0, %s2, (0)1
1788; CHECK-NEXT:    adds.l %s11, 16, %s11
1789; CHECK-NEXT:    b.l.t (, %s10)
1790bb:
1791  %i = alloca %"struct.std::__1::atomic.25", align 8
1792  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %i)
1793  %i4 = load i32, ptr %arg, align 4
1794  %i5 = cmpxchg weak volatile ptr %i, i32 %i4, i32 %arg1 monotonic monotonic, align 4
1795  %i6 = extractvalue { i32, i1 } %i5, 1
1796  br i1 %i6, label %bb9, label %bb7
1797
1798bb7:                                              ; preds = %bb
1799  %i8 = extractvalue { i32, i1 } %i5, 0
1800  store i32 %i8, ptr %arg, align 4
1801  br label %bb9
1802
1803bb9:                                              ; preds = %bb7, %bb
1804  %i10 = zext i1 %i6 to i32
1805  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %i)
1806  ret i32 %i10
1807}
1808
1809; Function Attrs: nofree nounwind mustprogress
1810define i64 @_Z31atomic_cmp_swap_relaxed_stk_i64Rll(ptr nocapture nonnull align 8 dereferenceable(8) %arg, i64 %arg1) {
1811; CHECK-LABEL: _Z31atomic_cmp_swap_relaxed_stk_i64Rll:
1812; CHECK:       # %bb.0: # %bb
1813; CHECK-NEXT:    adds.l %s11, -16, %s11
1814; CHECK-NEXT:    brge.l %s11, %s8, .LBB40_4
1815; CHECK-NEXT:  # %bb.3: # %bb
1816; CHECK-NEXT:    ld %s61, 24(, %s14)
1817; CHECK-NEXT:    or %s62, 0, %s0
1818; CHECK-NEXT:    lea %s63, 315
1819; CHECK-NEXT:    shm.l %s63, (%s61)
1820; CHECK-NEXT:    shm.l %s8, 8(%s61)
1821; CHECK-NEXT:    shm.l %s11, 16(%s61)
1822; CHECK-NEXT:    monc
1823; CHECK-NEXT:    or %s0, 0, %s62
1824; CHECK-NEXT:  .LBB40_4: # %bb
1825; CHECK-NEXT:    ld %s3, (, %s0)
1826; CHECK-NEXT:    cas.l %s1, 8(%s11), %s3
1827; CHECK-NEXT:    cmps.l %s4, %s1, %s3
1828; CHECK-NEXT:    or %s2, 0, (0)1
1829; CHECK-NEXT:    cmov.l.eq %s2, (63)0, %s4
1830; CHECK-NEXT:    breq.l %s1, %s3, .LBB40_2
1831; CHECK-NEXT:  # %bb.1: # %bb7
1832; CHECK-NEXT:    st %s1, (, %s0)
1833; CHECK-NEXT:  .LBB40_2: # %bb9
1834; CHECK-NEXT:    adds.w.zx %s0, %s2, (0)1
1835; CHECK-NEXT:    adds.l %s11, 16, %s11
1836; CHECK-NEXT:    b.l.t (, %s10)
1837bb:
1838  %i = alloca %"struct.std::__1::atomic.30", align 8
1839  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %i)
1840  %i4 = load i64, ptr %arg, align 8
1841  %i5 = cmpxchg weak volatile ptr %i, i64 %i4, i64 %arg1 monotonic monotonic, align 8
1842  %i6 = extractvalue { i64, i1 } %i5, 1
1843  br i1 %i6, label %bb9, label %bb7
1844
1845bb7:                                              ; preds = %bb
1846  %i8 = extractvalue { i64, i1 } %i5, 0
1847  store i64 %i8, ptr %arg, align 8
1848  br label %bb9
1849
1850bb9:                                              ; preds = %bb7, %bb
1851  %i10 = zext i1 %i6 to i64
1852  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %i)
1853  ret i64 %i10
1854}
1855
1856; Function Attrs: nofree nounwind mustprogress
1857define i64 @_Z31atomic_cmp_swap_relaxed_stk_u64Rmm(ptr nocapture nonnull align 8 dereferenceable(8) %arg, i64 %arg1) {
1858; CHECK-LABEL: _Z31atomic_cmp_swap_relaxed_stk_u64Rmm:
1859; CHECK:       # %bb.0: # %bb
1860; CHECK-NEXT:    adds.l %s11, -16, %s11
1861; CHECK-NEXT:    brge.l %s11, %s8, .LBB41_4
1862; CHECK-NEXT:  # %bb.3: # %bb
1863; CHECK-NEXT:    ld %s61, 24(, %s14)
1864; CHECK-NEXT:    or %s62, 0, %s0
1865; CHECK-NEXT:    lea %s63, 315
1866; CHECK-NEXT:    shm.l %s63, (%s61)
1867; CHECK-NEXT:    shm.l %s8, 8(%s61)
1868; CHECK-NEXT:    shm.l %s11, 16(%s61)
1869; CHECK-NEXT:    monc
1870; CHECK-NEXT:    or %s0, 0, %s62
1871; CHECK-NEXT:  .LBB41_4: # %bb
1872; CHECK-NEXT:    ld %s3, (, %s0)
1873; CHECK-NEXT:    cas.l %s1, 8(%s11), %s3
1874; CHECK-NEXT:    cmps.l %s4, %s1, %s3
1875; CHECK-NEXT:    or %s2, 0, (0)1
1876; CHECK-NEXT:    cmov.l.eq %s2, (63)0, %s4
1877; CHECK-NEXT:    breq.l %s1, %s3, .LBB41_2
1878; CHECK-NEXT:  # %bb.1: # %bb7
1879; CHECK-NEXT:    st %s1, (, %s0)
1880; CHECK-NEXT:  .LBB41_2: # %bb9
1881; CHECK-NEXT:    adds.w.zx %s0, %s2, (0)1
1882; CHECK-NEXT:    adds.l %s11, 16, %s11
1883; CHECK-NEXT:    b.l.t (, %s10)
1884bb:
1885  %i = alloca %"struct.std::__1::atomic.35", align 8
1886  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %i)
1887  %i4 = load i64, ptr %arg, align 8
1888  %i5 = cmpxchg weak volatile ptr %i, i64 %i4, i64 %arg1 monotonic monotonic, align 8
1889  %i6 = extractvalue { i64, i1 } %i5, 1
1890  br i1 %i6, label %bb9, label %bb7
1891
1892bb7:                                              ; preds = %bb
1893  %i8 = extractvalue { i64, i1 } %i5, 0
1894  store i64 %i8, ptr %arg, align 8
1895  br label %bb9
1896
1897bb9:                                              ; preds = %bb7, %bb
1898  %i10 = zext i1 %i6 to i64
1899  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %i)
1900  ret i64 %i10
1901}
1902
1903; Function Attrs: nounwind mustprogress
1904define i128 @_Z32atomic_cmp_swap_relaxed_stk_i128Rnn(ptr nonnull align 16 dereferenceable(16) %arg, i128 %arg1) {
1905; CHECK-LABEL: _Z32atomic_cmp_swap_relaxed_stk_i128Rnn:
1906; CHECK:       # %bb.0: # %bb
1907; CHECK-NEXT:    st %s9, (, %s11)
1908; CHECK-NEXT:    st %s10, 8(, %s11)
1909; CHECK-NEXT:    or %s9, 0, %s11
1910; CHECK-NEXT:    lea %s11, -272(, %s11)
1911; CHECK-NEXT:    brge.l.t %s11, %s8, .LBB42_2
1912; CHECK-NEXT:  # %bb.1: # %bb
1913; CHECK-NEXT:    ld %s61, 24(, %s14)
1914; CHECK-NEXT:    or %s62, 0, %s0
1915; CHECK-NEXT:    lea %s63, 315
1916; CHECK-NEXT:    shm.l %s63, (%s61)
1917; CHECK-NEXT:    shm.l %s8, 8(%s61)
1918; CHECK-NEXT:    shm.l %s11, 16(%s61)
1919; CHECK-NEXT:    monc
1920; CHECK-NEXT:    or %s0, 0, %s62
1921; CHECK-NEXT:  .LBB42_2: # %bb
1922; CHECK-NEXT:    or %s6, 0, %s0
1923; CHECK-NEXT:    st %s2, 264(, %s11)
1924; CHECK-NEXT:    st %s1, 256(, %s11)
1925; CHECK-NEXT:    lea %s0, __atomic_compare_exchange@lo
1926; CHECK-NEXT:    and %s0, %s0, (32)0
1927; CHECK-NEXT:    lea.sl %s12, __atomic_compare_exchange@hi(, %s0)
1928; CHECK-NEXT:    lea %s1, 240(, %s11)
1929; CHECK-NEXT:    lea %s3, 256(, %s11)
1930; CHECK-NEXT:    or %s0, 16, (0)1
1931; CHECK-NEXT:    or %s4, 0, (0)1
1932; CHECK-NEXT:    or %s5, 0, (0)1
1933; CHECK-NEXT:    or %s2, 0, %s6
1934; CHECK-NEXT:    bsic %s10, (, %s12)
1935; CHECK-NEXT:    or %s1, 0, (0)1
1936; CHECK-NEXT:    or %s11, 0, %s9
1937; CHECK-NEXT:    ld %s10, 8(, %s11)
1938; CHECK-NEXT:    ld %s9, (, %s11)
1939; CHECK-NEXT:    b.l.t (, %s10)
1940bb:
1941  %i = alloca i128, align 16
1942  %i2 = alloca %"struct.std::__1::atomic.40", align 16
1943  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %i2)
1944  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %i)
1945  store i128 %arg1, ptr %i, align 16, !tbaa !0
1946  %i6 = call zeroext i1 @__atomic_compare_exchange(i64 16, ptr nonnull %i2, ptr nonnull %arg, ptr nonnull %i, i32 signext 0, i32 signext 0)
1947  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %i)
1948  %i7 = zext i1 %i6 to i128
1949  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %i2)
1950  ret i128 %i7
1951}
1952
1953; Function Attrs: nounwind mustprogress
1954define i128 @_Z32atomic_cmp_swap_relaxed_stk_u128Roo(ptr nonnull align 16 dereferenceable(16) %arg, i128 %arg1) {
1955; CHECK-LABEL: _Z32atomic_cmp_swap_relaxed_stk_u128Roo:
1956; CHECK:       # %bb.0: # %bb
1957; CHECK-NEXT:    st %s9, (, %s11)
1958; CHECK-NEXT:    st %s10, 8(, %s11)
1959; CHECK-NEXT:    or %s9, 0, %s11
1960; CHECK-NEXT:    lea %s11, -272(, %s11)
1961; CHECK-NEXT:    brge.l.t %s11, %s8, .LBB43_2
1962; CHECK-NEXT:  # %bb.1: # %bb
1963; CHECK-NEXT:    ld %s61, 24(, %s14)
1964; CHECK-NEXT:    or %s62, 0, %s0
1965; CHECK-NEXT:    lea %s63, 315
1966; CHECK-NEXT:    shm.l %s63, (%s61)
1967; CHECK-NEXT:    shm.l %s8, 8(%s61)
1968; CHECK-NEXT:    shm.l %s11, 16(%s61)
1969; CHECK-NEXT:    monc
1970; CHECK-NEXT:    or %s0, 0, %s62
1971; CHECK-NEXT:  .LBB43_2: # %bb
1972; CHECK-NEXT:    or %s6, 0, %s0
1973; CHECK-NEXT:    st %s2, 264(, %s11)
1974; CHECK-NEXT:    st %s1, 256(, %s11)
1975; CHECK-NEXT:    lea %s0, __atomic_compare_exchange@lo
1976; CHECK-NEXT:    and %s0, %s0, (32)0
1977; CHECK-NEXT:    lea.sl %s12, __atomic_compare_exchange@hi(, %s0)
1978; CHECK-NEXT:    lea %s1, 240(, %s11)
1979; CHECK-NEXT:    lea %s3, 256(, %s11)
1980; CHECK-NEXT:    or %s0, 16, (0)1
1981; CHECK-NEXT:    or %s4, 0, (0)1
1982; CHECK-NEXT:    or %s5, 0, (0)1
1983; CHECK-NEXT:    or %s2, 0, %s6
1984; CHECK-NEXT:    bsic %s10, (, %s12)
1985; CHECK-NEXT:    or %s1, 0, (0)1
1986; CHECK-NEXT:    or %s11, 0, %s9
1987; CHECK-NEXT:    ld %s10, 8(, %s11)
1988; CHECK-NEXT:    ld %s9, (, %s11)
1989; CHECK-NEXT:    b.l.t (, %s10)
1990bb:
1991  %i = alloca i128, align 16
1992  %i2 = alloca %"struct.std::__1::atomic.45", align 16
1993  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %i2)
1994  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %i)
1995  store i128 %arg1, ptr %i, align 16, !tbaa !0
1996  %i6 = call zeroext i1 @__atomic_compare_exchange(i64 16, ptr nonnull %i2, ptr nonnull %arg, ptr nonnull %i, i32 signext 0, i32 signext 0)
1997  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %i)
1998  %i7 = zext i1 %i6 to i128
1999  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %i2)
2000  ret i128 %i7
2001}
2002
2003; Function Attrs: nofree norecurse nounwind mustprogress
2004define zeroext i1 @_Z29atomic_cmp_swap_relaxed_gv_i1Rbb(ptr nocapture nonnull align 1 dereferenceable(1) %arg, i1 zeroext %arg1) {
2005; CHECK-LABEL: _Z29atomic_cmp_swap_relaxed_gv_i1Rbb:
2006; CHECK:       # %bb.0: # %bb
2007; CHECK-NEXT:    and %s2, %s1, (32)0
2008; CHECK-NEXT:    lea %s1, gv_i1@lo
2009; CHECK-NEXT:    and %s1, %s1, (32)0
2010; CHECK-NEXT:    lea.sl %s1, gv_i1@hi(, %s1)
2011; CHECK-NEXT:    and %s1, -4, %s1
2012; CHECK-NEXT:    ldl.zx %s4, (, %s1)
2013; CHECK-NEXT:    ld1b.zx %s3, (, %s0)
2014; CHECK-NEXT:    lea %s5, -256
2015; CHECK-NEXT:    and %s5, %s5, (32)0
2016; CHECK-NEXT:    and %s4, %s4, %s5
2017; CHECK-NEXT:    and %s4, %s4, (32)0
2018; CHECK-NEXT:    or %s2, %s4, %s2
2019; CHECK-NEXT:    or %s3, %s4, %s3
2020; CHECK-NEXT:    cas.w %s2, (%s1), %s3
2021; CHECK-NEXT:    cmps.w.sx %s3, %s2, %s3
2022; CHECK-NEXT:    or %s1, 0, (0)1
2023; CHECK-NEXT:    cmov.w.eq %s1, (63)0, %s3
2024; CHECK-NEXT:    brne.w 0, %s1, .LBB44_2
2025; CHECK-NEXT:  # %bb.1: # %bb5
2026; CHECK-NEXT:    st1b %s2, (, %s0)
2027; CHECK-NEXT:  .LBB44_2: # %bb7
2028; CHECK-NEXT:    adds.w.zx %s0, %s1, (0)1
2029; CHECK-NEXT:    b.l.t (, %s10)
2030bb:
2031  %i = zext i1 %arg1 to i8
2032  %i2 = load i8, ptr %arg, align 1
2033  %i3 = cmpxchg weak ptr @gv_i1, i8 %i2, i8 %i monotonic monotonic, align 1
2034  %i4 = extractvalue { i8, i1 } %i3, 1
2035  br i1 %i4, label %bb7, label %bb5
2036
2037bb5:                                              ; preds = %bb
2038  %i6 = extractvalue { i8, i1 } %i3, 0
2039  store i8 %i6, ptr %arg, align 1
2040  br label %bb7
2041
2042bb7:                                              ; preds = %bb5, %bb
2043  ret i1 %i4
2044}
2045
2046; Function Attrs: nofree norecurse nounwind mustprogress
2047define signext i8 @_Z29atomic_cmp_swap_relaxed_gv_i8Rcc(ptr nocapture nonnull align 1 dereferenceable(1) %arg, i8 signext %arg1) {
2048; CHECK-LABEL: _Z29atomic_cmp_swap_relaxed_gv_i8Rcc:
2049; CHECK:       # %bb.0: # %bb
2050; CHECK-NEXT:    ld1b.zx %s2, (, %s0)
2051; CHECK-NEXT:    lea %s3, gv_i8@lo
2052; CHECK-NEXT:    and %s3, %s3, (32)0
2053; CHECK-NEXT:    lea.sl %s3, gv_i8@hi(, %s3)
2054; CHECK-NEXT:    and %s3, -4, %s3
2055; CHECK-NEXT:    and %s1, %s1, (56)0
2056; CHECK-NEXT:    ldl.zx %s4, (, %s3)
2057; CHECK-NEXT:    and %s1, %s1, (32)0
2058; CHECK-NEXT:    lea %s5, -256
2059; CHECK-NEXT:    and %s5, %s5, (32)0
2060; CHECK-NEXT:    and %s4, %s4, %s5
2061; CHECK-NEXT:    and %s4, %s4, (32)0
2062; CHECK-NEXT:    or %s1, %s4, %s1
2063; CHECK-NEXT:    or %s2, %s4, %s2
2064; CHECK-NEXT:    cas.w %s1, (%s3), %s2
2065; CHECK-NEXT:    cmps.w.sx %s3, %s1, %s2
2066; CHECK-NEXT:    or %s2, 0, (0)1
2067; CHECK-NEXT:    cmov.w.eq %s2, (63)0, %s3
2068; CHECK-NEXT:    brne.w 0, %s2, .LBB45_2
2069; CHECK-NEXT:  # %bb.1: # %bb4
2070; CHECK-NEXT:    st1b %s1, (, %s0)
2071; CHECK-NEXT:  .LBB45_2: # %bb6
2072; CHECK-NEXT:    adds.w.zx %s0, %s2, (0)1
2073; CHECK-NEXT:    b.l.t (, %s10)
2074bb:
2075  %i = load i8, ptr %arg, align 1
2076  %i2 = cmpxchg weak ptr @gv_i8, i8 %i, i8 %arg1 monotonic monotonic, align 1
2077  %i3 = extractvalue { i8, i1 } %i2, 1
2078  br i1 %i3, label %bb6, label %bb4
2079
2080bb4:                                              ; preds = %bb
2081  %i5 = extractvalue { i8, i1 } %i2, 0
2082  store i8 %i5, ptr %arg, align 1
2083  br label %bb6
2084
2085bb6:                                              ; preds = %bb4, %bb
2086  %i7 = zext i1 %i3 to i8
2087  ret i8 %i7
2088}
2089
2090; Function Attrs: nofree norecurse nounwind mustprogress
2091define zeroext i8 @_Z29atomic_cmp_swap_relaxed_gv_u8Rhh(ptr nocapture nonnull align 1 dereferenceable(1) %arg, i8 zeroext %arg1) {
2092; CHECK-LABEL: _Z29atomic_cmp_swap_relaxed_gv_u8Rhh:
2093; CHECK:       # %bb.0: # %bb
2094; CHECK-NEXT:    and %s2, %s1, (32)0
2095; CHECK-NEXT:    lea %s1, gv_u8@lo
2096; CHECK-NEXT:    and %s1, %s1, (32)0
2097; CHECK-NEXT:    lea.sl %s1, gv_u8@hi(, %s1)
2098; CHECK-NEXT:    and %s1, -4, %s1
2099; CHECK-NEXT:    ldl.zx %s4, (, %s1)
2100; CHECK-NEXT:    ld1b.zx %s3, (, %s0)
2101; CHECK-NEXT:    lea %s5, -256
2102; CHECK-NEXT:    and %s5, %s5, (32)0
2103; CHECK-NEXT:    and %s4, %s4, %s5
2104; CHECK-NEXT:    and %s4, %s4, (32)0
2105; CHECK-NEXT:    or %s2, %s4, %s2
2106; CHECK-NEXT:    or %s3, %s4, %s3
2107; CHECK-NEXT:    cas.w %s2, (%s1), %s3
2108; CHECK-NEXT:    cmps.w.sx %s3, %s2, %s3
2109; CHECK-NEXT:    or %s1, 0, (0)1
2110; CHECK-NEXT:    cmov.w.eq %s1, (63)0, %s3
2111; CHECK-NEXT:    brne.w 0, %s1, .LBB46_2
2112; CHECK-NEXT:  # %bb.1: # %bb4
2113; CHECK-NEXT:    st1b %s2, (, %s0)
2114; CHECK-NEXT:  .LBB46_2: # %bb6
2115; CHECK-NEXT:    adds.w.zx %s0, %s1, (0)1
2116; CHECK-NEXT:    b.l.t (, %s10)
2117bb:
2118  %i = load i8, ptr %arg, align 1
2119  %i2 = cmpxchg weak ptr @gv_u8, i8 %i, i8 %arg1 monotonic monotonic, align 1
2120  %i3 = extractvalue { i8, i1 } %i2, 1
2121  br i1 %i3, label %bb6, label %bb4
2122
2123bb4:                                              ; preds = %bb
2124  %i5 = extractvalue { i8, i1 } %i2, 0
2125  store i8 %i5, ptr %arg, align 1
2126  br label %bb6
2127
2128bb6:                                              ; preds = %bb4, %bb
2129  %i7 = zext i1 %i3 to i8
2130  ret i8 %i7
2131}
2132
2133; Function Attrs: nofree norecurse nounwind mustprogress
2134define signext i16 @_Z30atomic_cmp_swap_relaxed_gv_i16Rss(ptr nocapture nonnull align 2 dereferenceable(2) %arg, i16 signext %arg1) {
2135; CHECK-LABEL: _Z30atomic_cmp_swap_relaxed_gv_i16Rss:
2136; CHECK:       # %bb.0: # %bb
2137; CHECK-NEXT:    lea %s2, gv_i16@lo
2138; CHECK-NEXT:    and %s2, %s2, (32)0
2139; CHECK-NEXT:    lea.sl %s2, gv_i16@hi(, %s2)
2140; CHECK-NEXT:    and %s2, -4, %s2
2141; CHECK-NEXT:    ld2b.zx %s4, 2(, %s2)
2142; CHECK-NEXT:    ld2b.zx %s3, (, %s0)
2143; CHECK-NEXT:    and %s1, %s1, (48)0
2144; CHECK-NEXT:    and %s1, %s1, (32)0
2145; CHECK-NEXT:    sla.w.sx %s4, %s4, 16
2146; CHECK-NEXT:    or %s1, %s4, %s1
2147; CHECK-NEXT:    or %s3, %s4, %s3
2148; CHECK-NEXT:    cas.w %s1, (%s2), %s3
2149; CHECK-NEXT:    cmps.w.sx %s3, %s1, %s3
2150; CHECK-NEXT:    or %s2, 0, (0)1
2151; CHECK-NEXT:    cmov.w.eq %s2, (63)0, %s3
2152; CHECK-NEXT:    brne.w 0, %s2, .LBB47_2
2153; CHECK-NEXT:  # %bb.1: # %bb4
2154; CHECK-NEXT:    st2b %s1, (, %s0)
2155; CHECK-NEXT:  .LBB47_2: # %bb6
2156; CHECK-NEXT:    adds.w.zx %s0, %s2, (0)1
2157; CHECK-NEXT:    b.l.t (, %s10)
2158bb:
2159  %i = load i16, ptr %arg, align 2
2160  %i2 = cmpxchg weak ptr @gv_i16, i16 %i, i16 %arg1 monotonic monotonic, align 2
2161  %i3 = extractvalue { i16, i1 } %i2, 1
2162  br i1 %i3, label %bb6, label %bb4
2163
2164bb4:                                              ; preds = %bb
2165  %i5 = extractvalue { i16, i1 } %i2, 0
2166  store i16 %i5, ptr %arg, align 2
2167  br label %bb6
2168
2169bb6:                                              ; preds = %bb4, %bb
2170  %i7 = zext i1 %i3 to i16
2171  ret i16 %i7
2172}
2173
2174; Function Attrs: nofree norecurse nounwind mustprogress
2175define zeroext i16 @_Z30atomic_cmp_swap_relaxed_gv_u16Rtt(ptr nocapture nonnull align 2 dereferenceable(2) %arg, i16 zeroext %arg1) {
2176; CHECK-LABEL: _Z30atomic_cmp_swap_relaxed_gv_u16Rtt:
2177; CHECK:       # %bb.0: # %bb
2178; CHECK-NEXT:    lea %s2, gv_u16@lo
2179; CHECK-NEXT:    and %s2, %s2, (32)0
2180; CHECK-NEXT:    lea.sl %s2, gv_u16@hi(, %s2)
2181; CHECK-NEXT:    and %s2, -4, %s2
2182; CHECK-NEXT:    ld2b.zx %s4, 2(, %s2)
2183; CHECK-NEXT:    ld2b.zx %s3, (, %s0)
2184; CHECK-NEXT:    and %s1, %s1, (32)0
2185; CHECK-NEXT:    sla.w.sx %s4, %s4, 16
2186; CHECK-NEXT:    or %s1, %s4, %s1
2187; CHECK-NEXT:    or %s3, %s4, %s3
2188; CHECK-NEXT:    cas.w %s1, (%s2), %s3
2189; CHECK-NEXT:    cmps.w.sx %s3, %s1, %s3
2190; CHECK-NEXT:    or %s2, 0, (0)1
2191; CHECK-NEXT:    cmov.w.eq %s2, (63)0, %s3
2192; CHECK-NEXT:    brne.w 0, %s2, .LBB48_2
2193; CHECK-NEXT:  # %bb.1: # %bb4
2194; CHECK-NEXT:    st2b %s1, (, %s0)
2195; CHECK-NEXT:  .LBB48_2: # %bb6
2196; CHECK-NEXT:    adds.w.zx %s0, %s2, (0)1
2197; CHECK-NEXT:    b.l.t (, %s10)
2198bb:
2199  %i = load i16, ptr %arg, align 2
2200  %i2 = cmpxchg weak ptr @gv_u16, i16 %i, i16 %arg1 monotonic monotonic, align 2
2201  %i3 = extractvalue { i16, i1 } %i2, 1
2202  br i1 %i3, label %bb6, label %bb4
2203
2204bb4:                                              ; preds = %bb
2205  %i5 = extractvalue { i16, i1 } %i2, 0
2206  store i16 %i5, ptr %arg, align 2
2207  br label %bb6
2208
2209bb6:                                              ; preds = %bb4, %bb
2210  %i7 = zext i1 %i3 to i16
2211  ret i16 %i7
2212}
2213
2214; Function Attrs: nofree norecurse nounwind mustprogress
2215define signext i32 @_Z30atomic_cmp_swap_relaxed_gv_i32Rii(ptr nocapture nonnull align 4 dereferenceable(4) %arg, i32 signext %arg1) {
2216; CHECK-LABEL: _Z30atomic_cmp_swap_relaxed_gv_i32Rii:
2217; CHECK:       # %bb.0: # %bb
2218; CHECK-NEXT:    ldl.sx %s3, (, %s0)
2219; CHECK-NEXT:    lea %s2, gv_i32@lo
2220; CHECK-NEXT:    and %s2, %s2, (32)0
2221; CHECK-NEXT:    lea.sl %s2, gv_i32@hi(, %s2)
2222; CHECK-NEXT:    cas.w %s1, (%s2), %s3
2223; CHECK-NEXT:    cmps.w.sx %s4, %s1, %s3
2224; CHECK-NEXT:    or %s2, 0, (0)1
2225; CHECK-NEXT:    cmov.w.eq %s2, (63)0, %s4
2226; CHECK-NEXT:    breq.w %s1, %s3, .LBB49_2
2227; CHECK-NEXT:  # %bb.1: # %bb4
2228; CHECK-NEXT:    stl %s1, (, %s0)
2229; CHECK-NEXT:  .LBB49_2: # %bb6
2230; CHECK-NEXT:    adds.w.zx %s0, %s2, (0)1
2231; CHECK-NEXT:    b.l.t (, %s10)
2232bb:
2233  %i = load i32, ptr %arg, align 4
2234  %i2 = cmpxchg weak ptr @gv_i32, i32 %i, i32 %arg1 monotonic monotonic, align 4
2235  %i3 = extractvalue { i32, i1 } %i2, 1
2236  br i1 %i3, label %bb6, label %bb4
2237
2238bb4:                                              ; preds = %bb
2239  %i5 = extractvalue { i32, i1 } %i2, 0
2240  store i32 %i5, ptr %arg, align 4
2241  br label %bb6
2242
2243bb6:                                              ; preds = %bb4, %bb
2244  %i7 = zext i1 %i3 to i32
2245  ret i32 %i7
2246}
2247
2248; Function Attrs: nofree norecurse nounwind mustprogress
2249define zeroext i32 @_Z30atomic_cmp_swap_relaxed_gv_u32Rjj(ptr nocapture nonnull align 4 dereferenceable(4) %arg, i32 zeroext %arg1) {
2250; CHECK-LABEL: _Z30atomic_cmp_swap_relaxed_gv_u32Rjj:
2251; CHECK:       # %bb.0: # %bb
2252; CHECK-NEXT:    ldl.sx %s3, (, %s0)
2253; CHECK-NEXT:    lea %s2, gv_u32@lo
2254; CHECK-NEXT:    and %s2, %s2, (32)0
2255; CHECK-NEXT:    lea.sl %s2, gv_u32@hi(, %s2)
2256; CHECK-NEXT:    cas.w %s1, (%s2), %s3
2257; CHECK-NEXT:    cmps.w.sx %s4, %s1, %s3
2258; CHECK-NEXT:    or %s2, 0, (0)1
2259; CHECK-NEXT:    cmov.w.eq %s2, (63)0, %s4
2260; CHECK-NEXT:    breq.w %s1, %s3, .LBB50_2
2261; CHECK-NEXT:  # %bb.1: # %bb4
2262; CHECK-NEXT:    stl %s1, (, %s0)
2263; CHECK-NEXT:  .LBB50_2: # %bb6
2264; CHECK-NEXT:    adds.w.zx %s0, %s2, (0)1
2265; CHECK-NEXT:    b.l.t (, %s10)
2266bb:
2267  %i = load i32, ptr %arg, align 4
2268  %i2 = cmpxchg weak ptr @gv_u32, i32 %i, i32 %arg1 monotonic monotonic, align 4
2269  %i3 = extractvalue { i32, i1 } %i2, 1
2270  br i1 %i3, label %bb6, label %bb4
2271
2272bb4:                                              ; preds = %bb
2273  %i5 = extractvalue { i32, i1 } %i2, 0
2274  store i32 %i5, ptr %arg, align 4
2275  br label %bb6
2276
2277bb6:                                              ; preds = %bb4, %bb
2278  %i7 = zext i1 %i3 to i32
2279  ret i32 %i7
2280}
2281
2282; Function Attrs: nofree norecurse nounwind mustprogress
2283define i64 @_Z30atomic_cmp_swap_relaxed_gv_i64Rll(ptr nocapture nonnull align 8 dereferenceable(8) %arg, i64 %arg1) {
2284; CHECK-LABEL: _Z30atomic_cmp_swap_relaxed_gv_i64Rll:
2285; CHECK:       # %bb.0: # %bb
2286; CHECK-NEXT:    ld %s3, (, %s0)
2287; CHECK-NEXT:    lea %s2, gv_i64@lo
2288; CHECK-NEXT:    and %s2, %s2, (32)0
2289; CHECK-NEXT:    lea.sl %s2, gv_i64@hi(, %s2)
2290; CHECK-NEXT:    cas.l %s1, (%s2), %s3
2291; CHECK-NEXT:    cmps.l %s4, %s1, %s3
2292; CHECK-NEXT:    or %s2, 0, (0)1
2293; CHECK-NEXT:    cmov.l.eq %s2, (63)0, %s4
2294; CHECK-NEXT:    breq.l %s1, %s3, .LBB51_2
2295; CHECK-NEXT:  # %bb.1: # %bb4
2296; CHECK-NEXT:    st %s1, (, %s0)
2297; CHECK-NEXT:  .LBB51_2: # %bb6
2298; CHECK-NEXT:    adds.w.zx %s0, %s2, (0)1
2299; CHECK-NEXT:    b.l.t (, %s10)
2300bb:
2301  %i = load i64, ptr %arg, align 8
2302  %i2 = cmpxchg weak ptr @gv_i64, i64 %i, i64 %arg1 monotonic monotonic, align 8
2303  %i3 = extractvalue { i64, i1 } %i2, 1
2304  br i1 %i3, label %bb6, label %bb4
2305
2306bb4:                                              ; preds = %bb
2307  %i5 = extractvalue { i64, i1 } %i2, 0
2308  store i64 %i5, ptr %arg, align 8
2309  br label %bb6
2310
2311bb6:                                              ; preds = %bb4, %bb
2312  %i7 = zext i1 %i3 to i64
2313  ret i64 %i7
2314}
2315
2316; Function Attrs: nofree norecurse nounwind mustprogress
2317define i64 @_Z30atomic_cmp_swap_relaxed_gv_u64Rmm(ptr nocapture nonnull align 8 dereferenceable(8) %arg, i64 %arg1) {
2318; CHECK-LABEL: _Z30atomic_cmp_swap_relaxed_gv_u64Rmm:
2319; CHECK:       # %bb.0: # %bb
2320; CHECK-NEXT:    ld %s3, (, %s0)
2321; CHECK-NEXT:    lea %s2, gv_u64@lo
2322; CHECK-NEXT:    and %s2, %s2, (32)0
2323; CHECK-NEXT:    lea.sl %s2, gv_u64@hi(, %s2)
2324; CHECK-NEXT:    cas.l %s1, (%s2), %s3
2325; CHECK-NEXT:    cmps.l %s4, %s1, %s3
2326; CHECK-NEXT:    or %s2, 0, (0)1
2327; CHECK-NEXT:    cmov.l.eq %s2, (63)0, %s4
2328; CHECK-NEXT:    breq.l %s1, %s3, .LBB52_2
2329; CHECK-NEXT:  # %bb.1: # %bb4
2330; CHECK-NEXT:    st %s1, (, %s0)
2331; CHECK-NEXT:  .LBB52_2: # %bb6
2332; CHECK-NEXT:    adds.w.zx %s0, %s2, (0)1
2333; CHECK-NEXT:    b.l.t (, %s10)
2334bb:
2335  %i = load i64, ptr %arg, align 8
2336  %i2 = cmpxchg weak ptr @gv_u64, i64 %i, i64 %arg1 monotonic monotonic, align 8
2337  %i3 = extractvalue { i64, i1 } %i2, 1
2338  br i1 %i3, label %bb6, label %bb4
2339
2340bb4:                                              ; preds = %bb
2341  %i5 = extractvalue { i64, i1 } %i2, 0
2342  store i64 %i5, ptr %arg, align 8
2343  br label %bb6
2344
2345bb6:                                              ; preds = %bb4, %bb
2346  %i7 = zext i1 %i3 to i64
2347  ret i64 %i7
2348}
2349
2350; Function Attrs: nounwind mustprogress
2351define i128 @_Z31atomic_cmp_swap_relaxed_gv_i128Rnn(ptr nonnull align 16 dereferenceable(16) %arg, i128 %arg1) {
2352; CHECK-LABEL: _Z31atomic_cmp_swap_relaxed_gv_i128Rnn:
2353; CHECK:       # %bb.0: # %bb
2354; CHECK-NEXT:    st %s9, (, %s11)
2355; CHECK-NEXT:    st %s10, 8(, %s11)
2356; CHECK-NEXT:    or %s9, 0, %s11
2357; CHECK-NEXT:    lea %s11, -256(, %s11)
2358; CHECK-NEXT:    brge.l.t %s11, %s8, .LBB53_2
2359; CHECK-NEXT:  # %bb.1: # %bb
2360; CHECK-NEXT:    ld %s61, 24(, %s14)
2361; CHECK-NEXT:    or %s62, 0, %s0
2362; CHECK-NEXT:    lea %s63, 315
2363; CHECK-NEXT:    shm.l %s63, (%s61)
2364; CHECK-NEXT:    shm.l %s8, 8(%s61)
2365; CHECK-NEXT:    shm.l %s11, 16(%s61)
2366; CHECK-NEXT:    monc
2367; CHECK-NEXT:    or %s0, 0, %s62
2368; CHECK-NEXT:  .LBB53_2: # %bb
2369; CHECK-NEXT:    or %s6, 0, %s0
2370; CHECK-NEXT:    st %s2, 248(, %s11)
2371; CHECK-NEXT:    st %s1, 240(, %s11)
2372; CHECK-NEXT:    lea %s0, __atomic_compare_exchange@lo
2373; CHECK-NEXT:    and %s0, %s0, (32)0
2374; CHECK-NEXT:    lea.sl %s12, __atomic_compare_exchange@hi(, %s0)
2375; CHECK-NEXT:    lea %s0, gv_i128@lo
2376; CHECK-NEXT:    and %s0, %s0, (32)0
2377; CHECK-NEXT:    lea.sl %s1, gv_i128@hi(, %s0)
2378; CHECK-NEXT:    lea %s3, 240(, %s11)
2379; CHECK-NEXT:    or %s0, 16, (0)1
2380; CHECK-NEXT:    or %s4, 0, (0)1
2381; CHECK-NEXT:    or %s5, 0, (0)1
2382; CHECK-NEXT:    or %s2, 0, %s6
2383; CHECK-NEXT:    bsic %s10, (, %s12)
2384; CHECK-NEXT:    or %s1, 0, (0)1
2385; CHECK-NEXT:    or %s11, 0, %s9
2386; CHECK-NEXT:    ld %s10, 8(, %s11)
2387; CHECK-NEXT:    ld %s9, (, %s11)
2388; CHECK-NEXT:    b.l.t (, %s10)
2389bb:
2390  %i = alloca i128, align 16
2391  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %i)
2392  store i128 %arg1, ptr %i, align 16, !tbaa !0
2393  %i4 = call zeroext i1 @__atomic_compare_exchange(i64 16, ptr nonnull @gv_i128, ptr nonnull %arg, ptr nonnull %i, i32 signext 0, i32 signext 0)
2394  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %i)
2395  %i5 = zext i1 %i4 to i128
2396  ret i128 %i5
2397}
2398
2399; Function Attrs: nounwind mustprogress
2400define i128 @_Z31atomic_cmp_swap_relaxed_gv_u128Roo(ptr nonnull align 16 dereferenceable(16) %arg, i128 %arg1) {
2401; CHECK-LABEL: _Z31atomic_cmp_swap_relaxed_gv_u128Roo:
2402; CHECK:       # %bb.0: # %bb
2403; CHECK-NEXT:    st %s9, (, %s11)
2404; CHECK-NEXT:    st %s10, 8(, %s11)
2405; CHECK-NEXT:    or %s9, 0, %s11
2406; CHECK-NEXT:    lea %s11, -256(, %s11)
2407; CHECK-NEXT:    brge.l.t %s11, %s8, .LBB54_2
2408; CHECK-NEXT:  # %bb.1: # %bb
2409; CHECK-NEXT:    ld %s61, 24(, %s14)
2410; CHECK-NEXT:    or %s62, 0, %s0
2411; CHECK-NEXT:    lea %s63, 315
2412; CHECK-NEXT:    shm.l %s63, (%s61)
2413; CHECK-NEXT:    shm.l %s8, 8(%s61)
2414; CHECK-NEXT:    shm.l %s11, 16(%s61)
2415; CHECK-NEXT:    monc
2416; CHECK-NEXT:    or %s0, 0, %s62
2417; CHECK-NEXT:  .LBB54_2: # %bb
2418; CHECK-NEXT:    or %s6, 0, %s0
2419; CHECK-NEXT:    st %s2, 248(, %s11)
2420; CHECK-NEXT:    st %s1, 240(, %s11)
2421; CHECK-NEXT:    lea %s0, __atomic_compare_exchange@lo
2422; CHECK-NEXT:    and %s0, %s0, (32)0
2423; CHECK-NEXT:    lea.sl %s12, __atomic_compare_exchange@hi(, %s0)
2424; CHECK-NEXT:    lea %s0, gv_u128@lo
2425; CHECK-NEXT:    and %s0, %s0, (32)0
2426; CHECK-NEXT:    lea.sl %s1, gv_u128@hi(, %s0)
2427; CHECK-NEXT:    lea %s3, 240(, %s11)
2428; CHECK-NEXT:    or %s0, 16, (0)1
2429; CHECK-NEXT:    or %s4, 0, (0)1
2430; CHECK-NEXT:    or %s5, 0, (0)1
2431; CHECK-NEXT:    or %s2, 0, %s6
2432; CHECK-NEXT:    bsic %s10, (, %s12)
2433; CHECK-NEXT:    or %s1, 0, (0)1
2434; CHECK-NEXT:    or %s11, 0, %s9
2435; CHECK-NEXT:    ld %s10, 8(, %s11)
2436; CHECK-NEXT:    ld %s9, (, %s11)
2437; CHECK-NEXT:    b.l.t (, %s10)
2438bb:
2439  %i = alloca i128, align 16
2440  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %i)
2441  store i128 %arg1, ptr %i, align 16, !tbaa !0
2442  %i4 = call zeroext i1 @__atomic_compare_exchange(i64 16, ptr nonnull @gv_u128, ptr nonnull %arg, ptr nonnull %i, i32 signext 0, i32 signext 0)
2443  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %i)
2444  %i5 = zext i1 %i4 to i128
2445  ret i128 %i5
2446}
2447
2448; Function Attrs: nounwind willreturn
2449declare i1 @__atomic_compare_exchange(i64, ptr, ptr, ptr, i32, i32)
2450
2451!0 = !{!1, !1, i64 0}
2452!1 = !{!"__int128", !2, i64 0}
2453!2 = !{!"omnipotent char", !3, i64 0}
2454!3 = !{!"Simple C++ TBAA"}
2455