• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=mips64el-unknown-linux-gnu --disable-machine-licm -mcpu=mips4 -relocation-model=pic -verify-machineinstrs < %s | \
3; RUN:   FileCheck %s -check-prefix=MIPS4
4; RUN: llc -mtriple=mips64el-unknown-linux-gnu --disable-machine-licm -mcpu=mips64 -relocation-model=pic -verify-machineinstrs < %s | \
5; RUN:   FileCheck %s -check-prefix=MIPS64
6; RUN: llc -mtriple=mips64el-unknown-linux-gnu --disable-machine-licm -mcpu=mips64r2 -relocation-model=pic -verify-machineinstrs < %s | \
7; RUN:   FileCheck %s -check-prefix=MIPS64R2
8; RUN: llc -mtriple=mips64el-unknown-linux-gnu --disable-machine-licm -mcpu=mips64r6 -relocation-model=pic -verify-machineinstrs < %s | \
9; RUN:   FileCheck %s -check-prefix=MIPS64R6
10; RUN: llc -mtriple=mips64-unknown-linux-gnu -O0 -mcpu=mips64r6 -relocation-model=pic -verify-machineinstrs -verify-machineinstrs < %s | \
11; RUN:   FileCheck %s -check-prefix=MIPS64R6O0
12
13; We want to verify the produced code is well formed all optimization levels, the rest of the test which ensure correctness.
14; RUN: llc -mtriple=mips64el-unknown-linux-gnu -O1 --disable-machine-licm -mcpu=mips64 -relocation-model=pic -verify-machineinstrs < %s | FileCheck %s --check-prefix=O1
15; RUN: llc -mtriple=mips64el-unknown-linux-gnu -O2 --disable-machine-licm -mcpu=mips64 -relocation-model=pic -verify-machineinstrs < %s | FileCheck %s --check-prefix=O2
16; RUN: llc -mtriple=mips64el-unknown-linux-gnu -O3 --disable-machine-licm -mcpu=mips64 -relocation-model=pic -verify-machineinstrs < %s | FileCheck %s --check-prefix=O3
17
18; Keep one big-endian check so that we don't reduce testing, but don't add more
19; since endianness doesn't affect the body of the atomic operations.
20; RUN: llc -mtriple=mips64-unknown-linux-gnu --disable-machine-licm -mcpu=mips64 -relocation-model=pic -verify-machineinstrs < %s | \
21; RUN:   FileCheck %s -check-prefix=MIPS64EB
22
23@x = common global i64 0, align 4
24
25define i64 @AtomicLoadAdd(i64 signext %incr) nounwind {
26; MIPS4-LABEL: AtomicLoadAdd:
27; MIPS4:       # %bb.0: # %entry
28; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd)))
29; MIPS4-NEXT:    daddu $1, $1, $25
30; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd)))
31; MIPS4-NEXT:    ld $1, %got_disp(x)($1)
32; MIPS4-NEXT:  .LBB0_1: # %entry
33; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
34; MIPS4-NEXT:    lld $2, 0($1)
35; MIPS4-NEXT:    daddu $3, $2, $4
36; MIPS4-NEXT:    scd $3, 0($1)
37; MIPS4-NEXT:    beqz $3, .LBB0_1
38; MIPS4-NEXT:    nop
39; MIPS4-NEXT:  # %bb.2: # %entry
40; MIPS4-NEXT:    jr $ra
41; MIPS4-NEXT:    nop
42;
43; MIPS64-LABEL: AtomicLoadAdd:
44; MIPS64:       # %bb.0: # %entry
45; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd)))
46; MIPS64-NEXT:    daddu $1, $1, $25
47; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd)))
48; MIPS64-NEXT:    ld $1, %got_disp(x)($1)
49; MIPS64-NEXT:  .LBB0_1: # %entry
50; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
51; MIPS64-NEXT:    lld $2, 0($1)
52; MIPS64-NEXT:    daddu $3, $2, $4
53; MIPS64-NEXT:    scd $3, 0($1)
54; MIPS64-NEXT:    beqz $3, .LBB0_1
55; MIPS64-NEXT:    nop
56; MIPS64-NEXT:  # %bb.2: # %entry
57; MIPS64-NEXT:    jr $ra
58; MIPS64-NEXT:    nop
59;
60; MIPS64R2-LABEL: AtomicLoadAdd:
61; MIPS64R2:       # %bb.0: # %entry
62; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd)))
63; MIPS64R2-NEXT:    daddu $1, $1, $25
64; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd)))
65; MIPS64R2-NEXT:    ld $1, %got_disp(x)($1)
66; MIPS64R2-NEXT:  .LBB0_1: # %entry
67; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
68; MIPS64R2-NEXT:    lld $2, 0($1)
69; MIPS64R2-NEXT:    daddu $3, $2, $4
70; MIPS64R2-NEXT:    scd $3, 0($1)
71; MIPS64R2-NEXT:    beqz $3, .LBB0_1
72; MIPS64R2-NEXT:    nop
73; MIPS64R2-NEXT:  # %bb.2: # %entry
74; MIPS64R2-NEXT:    jr $ra
75; MIPS64R2-NEXT:    nop
76;
77; MIPS64R6-LABEL: AtomicLoadAdd:
78; MIPS64R6:       # %bb.0: # %entry
79; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd)))
80; MIPS64R6-NEXT:    daddu $1, $1, $25
81; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd)))
82; MIPS64R6-NEXT:    ld $1, %got_disp(x)($1)
83; MIPS64R6-NEXT:  .LBB0_1: # %entry
84; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
85; MIPS64R6-NEXT:    lld $2, 0($1)
86; MIPS64R6-NEXT:    daddu $3, $2, $4
87; MIPS64R6-NEXT:    scd $3, 0($1)
88; MIPS64R6-NEXT:    beqzc $3, .LBB0_1
89; MIPS64R6-NEXT:    nop
90; MIPS64R6-NEXT:  # %bb.2: # %entry
91; MIPS64R6-NEXT:    jrc $ra
92;
93; MIPS64R6O0-LABEL: AtomicLoadAdd:
94; MIPS64R6O0:       # %bb.0: # %entry
95; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -16
96; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd)))
97; MIPS64R6O0-NEXT:    daddu $1, $1, $25
98; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd)))
99; MIPS64R6O0-NEXT:    move $25, $4
100; MIPS64R6O0-NEXT:    ld $1, %got_disp(x)($1)
101; MIPS64R6O0-NEXT:  .LBB0_1: # %entry
102; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
103; MIPS64R6O0-NEXT:    lld $2, 0($1)
104; MIPS64R6O0-NEXT:    daddu $3, $2, $4
105; MIPS64R6O0-NEXT:    scd $3, 0($1)
106; MIPS64R6O0-NEXT:    beqzc $3, .LBB0_1
107; MIPS64R6O0-NEXT:  # %bb.2: # %entry
108; MIPS64R6O0-NEXT:    sd $25, 8($sp) # 8-byte Folded Spill
109; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 16
110; MIPS64R6O0-NEXT:    jrc $ra
111;
112; O1-LABEL: AtomicLoadAdd:
113; O1:       # %bb.0: # %entry
114; O1-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd)))
115; O1-NEXT:    daddu $1, $1, $25
116; O1-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd)))
117; O1-NEXT:    ld $1, %got_disp(x)($1)
118; O1-NEXT:  .LBB0_1: # %entry
119; O1-NEXT:    # =>This Inner Loop Header: Depth=1
120; O1-NEXT:    lld $2, 0($1)
121; O1-NEXT:    daddu $3, $2, $4
122; O1-NEXT:    scd $3, 0($1)
123; O1-NEXT:    beqz $3, .LBB0_1
124; O1-NEXT:    nop
125; O1-NEXT:  # %bb.2: # %entry
126; O1-NEXT:    jr $ra
127; O1-NEXT:    nop
128;
129; O2-LABEL: AtomicLoadAdd:
130; O2:       # %bb.0: # %entry
131; O2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd)))
132; O2-NEXT:    daddu $1, $1, $25
133; O2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd)))
134; O2-NEXT:    ld $1, %got_disp(x)($1)
135; O2-NEXT:  .LBB0_1: # %entry
136; O2-NEXT:    # =>This Inner Loop Header: Depth=1
137; O2-NEXT:    lld $2, 0($1)
138; O2-NEXT:    daddu $3, $2, $4
139; O2-NEXT:    scd $3, 0($1)
140; O2-NEXT:    beqz $3, .LBB0_1
141; O2-NEXT:    nop
142; O2-NEXT:  # %bb.2: # %entry
143; O2-NEXT:    jr $ra
144; O2-NEXT:    nop
145;
146; O3-LABEL: AtomicLoadAdd:
147; O3:       # %bb.0: # %entry
148; O3-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd)))
149; O3-NEXT:    daddu $1, $1, $25
150; O3-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd)))
151; O3-NEXT:    ld $1, %got_disp(x)($1)
152; O3-NEXT:  .LBB0_1: # %entry
153; O3-NEXT:    # =>This Inner Loop Header: Depth=1
154; O3-NEXT:    lld $2, 0($1)
155; O3-NEXT:    daddu $3, $2, $4
156; O3-NEXT:    scd $3, 0($1)
157; O3-NEXT:    beqz $3, .LBB0_1
158; O3-NEXT:    nop
159; O3-NEXT:  # %bb.2: # %entry
160; O3-NEXT:    jr $ra
161; O3-NEXT:    nop
162;
163; MIPS64EB-LABEL: AtomicLoadAdd:
164; MIPS64EB:       # %bb.0: # %entry
165; MIPS64EB-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd)))
166; MIPS64EB-NEXT:    daddu $1, $1, $25
167; MIPS64EB-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd)))
168; MIPS64EB-NEXT:    ld $1, %got_disp(x)($1)
169; MIPS64EB-NEXT:  .LBB0_1: # %entry
170; MIPS64EB-NEXT:    # =>This Inner Loop Header: Depth=1
171; MIPS64EB-NEXT:    lld $2, 0($1)
172; MIPS64EB-NEXT:    daddu $3, $2, $4
173; MIPS64EB-NEXT:    scd $3, 0($1)
174; MIPS64EB-NEXT:    beqz $3, .LBB0_1
175; MIPS64EB-NEXT:    nop
176; MIPS64EB-NEXT:  # %bb.2: # %entry
177; MIPS64EB-NEXT:    jr $ra
178; MIPS64EB-NEXT:    nop
179entry:
180  %0 = atomicrmw add i64* @x, i64 %incr monotonic
181  ret i64 %0
182
183}
184
185define i64 @AtomicLoadSub(i64 signext %incr) nounwind {
186; MIPS4-LABEL: AtomicLoadSub:
187; MIPS4:       # %bb.0: # %entry
188; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub)))
189; MIPS4-NEXT:    daddu $1, $1, $25
190; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub)))
191; MIPS4-NEXT:    ld $1, %got_disp(x)($1)
192; MIPS4-NEXT:  .LBB1_1: # %entry
193; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
194; MIPS4-NEXT:    lld $2, 0($1)
195; MIPS4-NEXT:    dsubu $3, $2, $4
196; MIPS4-NEXT:    scd $3, 0($1)
197; MIPS4-NEXT:    beqz $3, .LBB1_1
198; MIPS4-NEXT:    nop
199; MIPS4-NEXT:  # %bb.2: # %entry
200; MIPS4-NEXT:    jr $ra
201; MIPS4-NEXT:    nop
202;
203; MIPS64-LABEL: AtomicLoadSub:
204; MIPS64:       # %bb.0: # %entry
205; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub)))
206; MIPS64-NEXT:    daddu $1, $1, $25
207; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub)))
208; MIPS64-NEXT:    ld $1, %got_disp(x)($1)
209; MIPS64-NEXT:  .LBB1_1: # %entry
210; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
211; MIPS64-NEXT:    lld $2, 0($1)
212; MIPS64-NEXT:    dsubu $3, $2, $4
213; MIPS64-NEXT:    scd $3, 0($1)
214; MIPS64-NEXT:    beqz $3, .LBB1_1
215; MIPS64-NEXT:    nop
216; MIPS64-NEXT:  # %bb.2: # %entry
217; MIPS64-NEXT:    jr $ra
218; MIPS64-NEXT:    nop
219;
220; MIPS64R2-LABEL: AtomicLoadSub:
221; MIPS64R2:       # %bb.0: # %entry
222; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub)))
223; MIPS64R2-NEXT:    daddu $1, $1, $25
224; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub)))
225; MIPS64R2-NEXT:    ld $1, %got_disp(x)($1)
226; MIPS64R2-NEXT:  .LBB1_1: # %entry
227; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
228; MIPS64R2-NEXT:    lld $2, 0($1)
229; MIPS64R2-NEXT:    dsubu $3, $2, $4
230; MIPS64R2-NEXT:    scd $3, 0($1)
231; MIPS64R2-NEXT:    beqz $3, .LBB1_1
232; MIPS64R2-NEXT:    nop
233; MIPS64R2-NEXT:  # %bb.2: # %entry
234; MIPS64R2-NEXT:    jr $ra
235; MIPS64R2-NEXT:    nop
236;
237; MIPS64R6-LABEL: AtomicLoadSub:
238; MIPS64R6:       # %bb.0: # %entry
239; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub)))
240; MIPS64R6-NEXT:    daddu $1, $1, $25
241; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub)))
242; MIPS64R6-NEXT:    ld $1, %got_disp(x)($1)
243; MIPS64R6-NEXT:  .LBB1_1: # %entry
244; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
245; MIPS64R6-NEXT:    lld $2, 0($1)
246; MIPS64R6-NEXT:    dsubu $3, $2, $4
247; MIPS64R6-NEXT:    scd $3, 0($1)
248; MIPS64R6-NEXT:    beqzc $3, .LBB1_1
249; MIPS64R6-NEXT:    nop
250; MIPS64R6-NEXT:  # %bb.2: # %entry
251; MIPS64R6-NEXT:    jrc $ra
252;
253; MIPS64R6O0-LABEL: AtomicLoadSub:
254; MIPS64R6O0:       # %bb.0: # %entry
255; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -16
256; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub)))
257; MIPS64R6O0-NEXT:    daddu $1, $1, $25
258; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub)))
259; MIPS64R6O0-NEXT:    move $25, $4
260; MIPS64R6O0-NEXT:    ld $1, %got_disp(x)($1)
261; MIPS64R6O0-NEXT:  .LBB1_1: # %entry
262; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
263; MIPS64R6O0-NEXT:    lld $2, 0($1)
264; MIPS64R6O0-NEXT:    dsubu $3, $2, $4
265; MIPS64R6O0-NEXT:    scd $3, 0($1)
266; MIPS64R6O0-NEXT:    beqzc $3, .LBB1_1
267; MIPS64R6O0-NEXT:  # %bb.2: # %entry
268; MIPS64R6O0-NEXT:    sd $25, 8($sp) # 8-byte Folded Spill
269; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 16
270; MIPS64R6O0-NEXT:    jrc $ra
271;
272; O1-LABEL: AtomicLoadSub:
273; O1:       # %bb.0: # %entry
274; O1-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub)))
275; O1-NEXT:    daddu $1, $1, $25
276; O1-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub)))
277; O1-NEXT:    ld $1, %got_disp(x)($1)
278; O1-NEXT:  .LBB1_1: # %entry
279; O1-NEXT:    # =>This Inner Loop Header: Depth=1
280; O1-NEXT:    lld $2, 0($1)
281; O1-NEXT:    dsubu $3, $2, $4
282; O1-NEXT:    scd $3, 0($1)
283; O1-NEXT:    beqz $3, .LBB1_1
284; O1-NEXT:    nop
285; O1-NEXT:  # %bb.2: # %entry
286; O1-NEXT:    jr $ra
287; O1-NEXT:    nop
288;
289; O2-LABEL: AtomicLoadSub:
290; O2:       # %bb.0: # %entry
291; O2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub)))
292; O2-NEXT:    daddu $1, $1, $25
293; O2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub)))
294; O2-NEXT:    ld $1, %got_disp(x)($1)
295; O2-NEXT:  .LBB1_1: # %entry
296; O2-NEXT:    # =>This Inner Loop Header: Depth=1
297; O2-NEXT:    lld $2, 0($1)
298; O2-NEXT:    dsubu $3, $2, $4
299; O2-NEXT:    scd $3, 0($1)
300; O2-NEXT:    beqz $3, .LBB1_1
301; O2-NEXT:    nop
302; O2-NEXT:  # %bb.2: # %entry
303; O2-NEXT:    jr $ra
304; O2-NEXT:    nop
305;
306; O3-LABEL: AtomicLoadSub:
307; O3:       # %bb.0: # %entry
308; O3-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub)))
309; O3-NEXT:    daddu $1, $1, $25
310; O3-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub)))
311; O3-NEXT:    ld $1, %got_disp(x)($1)
312; O3-NEXT:  .LBB1_1: # %entry
313; O3-NEXT:    # =>This Inner Loop Header: Depth=1
314; O3-NEXT:    lld $2, 0($1)
315; O3-NEXT:    dsubu $3, $2, $4
316; O3-NEXT:    scd $3, 0($1)
317; O3-NEXT:    beqz $3, .LBB1_1
318; O3-NEXT:    nop
319; O3-NEXT:  # %bb.2: # %entry
320; O3-NEXT:    jr $ra
321; O3-NEXT:    nop
322;
323; MIPS64EB-LABEL: AtomicLoadSub:
324; MIPS64EB:       # %bb.0: # %entry
325; MIPS64EB-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub)))
326; MIPS64EB-NEXT:    daddu $1, $1, $25
327; MIPS64EB-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub)))
328; MIPS64EB-NEXT:    ld $1, %got_disp(x)($1)
329; MIPS64EB-NEXT:  .LBB1_1: # %entry
330; MIPS64EB-NEXT:    # =>This Inner Loop Header: Depth=1
331; MIPS64EB-NEXT:    lld $2, 0($1)
332; MIPS64EB-NEXT:    dsubu $3, $2, $4
333; MIPS64EB-NEXT:    scd $3, 0($1)
334; MIPS64EB-NEXT:    beqz $3, .LBB1_1
335; MIPS64EB-NEXT:    nop
336; MIPS64EB-NEXT:  # %bb.2: # %entry
337; MIPS64EB-NEXT:    jr $ra
338; MIPS64EB-NEXT:    nop
339entry:
340  %0 = atomicrmw sub i64* @x, i64 %incr monotonic
341  ret i64 %0
342
343}
344
345define i64 @AtomicLoadAnd(i64 signext %incr) nounwind {
346; MIPS4-LABEL: AtomicLoadAnd:
347; MIPS4:       # %bb.0: # %entry
348; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAnd)))
349; MIPS4-NEXT:    daddu $1, $1, $25
350; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAnd)))
351; MIPS4-NEXT:    ld $1, %got_disp(x)($1)
352; MIPS4-NEXT:  .LBB2_1: # %entry
353; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
354; MIPS4-NEXT:    lld $2, 0($1)
355; MIPS4-NEXT:    and $3, $2, $4
356; MIPS4-NEXT:    scd $3, 0($1)
357; MIPS4-NEXT:    beqz $3, .LBB2_1
358; MIPS4-NEXT:    nop
359; MIPS4-NEXT:  # %bb.2: # %entry
360; MIPS4-NEXT:    jr $ra
361; MIPS4-NEXT:    nop
362;
363; MIPS64-LABEL: AtomicLoadAnd:
364; MIPS64:       # %bb.0: # %entry
365; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAnd)))
366; MIPS64-NEXT:    daddu $1, $1, $25
367; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAnd)))
368; MIPS64-NEXT:    ld $1, %got_disp(x)($1)
369; MIPS64-NEXT:  .LBB2_1: # %entry
370; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
371; MIPS64-NEXT:    lld $2, 0($1)
372; MIPS64-NEXT:    and $3, $2, $4
373; MIPS64-NEXT:    scd $3, 0($1)
374; MIPS64-NEXT:    beqz $3, .LBB2_1
375; MIPS64-NEXT:    nop
376; MIPS64-NEXT:  # %bb.2: # %entry
377; MIPS64-NEXT:    jr $ra
378; MIPS64-NEXT:    nop
379;
380; MIPS64R2-LABEL: AtomicLoadAnd:
381; MIPS64R2:       # %bb.0: # %entry
382; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAnd)))
383; MIPS64R2-NEXT:    daddu $1, $1, $25
384; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAnd)))
385; MIPS64R2-NEXT:    ld $1, %got_disp(x)($1)
386; MIPS64R2-NEXT:  .LBB2_1: # %entry
387; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
388; MIPS64R2-NEXT:    lld $2, 0($1)
389; MIPS64R2-NEXT:    and $3, $2, $4
390; MIPS64R2-NEXT:    scd $3, 0($1)
391; MIPS64R2-NEXT:    beqz $3, .LBB2_1
392; MIPS64R2-NEXT:    nop
393; MIPS64R2-NEXT:  # %bb.2: # %entry
394; MIPS64R2-NEXT:    jr $ra
395; MIPS64R2-NEXT:    nop
396;
397; MIPS64R6-LABEL: AtomicLoadAnd:
398; MIPS64R6:       # %bb.0: # %entry
399; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAnd)))
400; MIPS64R6-NEXT:    daddu $1, $1, $25
401; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAnd)))
402; MIPS64R6-NEXT:    ld $1, %got_disp(x)($1)
403; MIPS64R6-NEXT:  .LBB2_1: # %entry
404; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
405; MIPS64R6-NEXT:    lld $2, 0($1)
406; MIPS64R6-NEXT:    and $3, $2, $4
407; MIPS64R6-NEXT:    scd $3, 0($1)
408; MIPS64R6-NEXT:    beqzc $3, .LBB2_1
409; MIPS64R6-NEXT:    nop
410; MIPS64R6-NEXT:  # %bb.2: # %entry
411; MIPS64R6-NEXT:    jrc $ra
412;
413; MIPS64R6O0-LABEL: AtomicLoadAnd:
414; MIPS64R6O0:       # %bb.0: # %entry
415; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -16
416; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAnd)))
417; MIPS64R6O0-NEXT:    daddu $1, $1, $25
418; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAnd)))
419; MIPS64R6O0-NEXT:    move $25, $4
420; MIPS64R6O0-NEXT:    ld $1, %got_disp(x)($1)
421; MIPS64R6O0-NEXT:  .LBB2_1: # %entry
422; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
423; MIPS64R6O0-NEXT:    lld $2, 0($1)
424; MIPS64R6O0-NEXT:    and $3, $2, $4
425; MIPS64R6O0-NEXT:    scd $3, 0($1)
426; MIPS64R6O0-NEXT:    beqzc $3, .LBB2_1
427; MIPS64R6O0-NEXT:  # %bb.2: # %entry
428; MIPS64R6O0-NEXT:    sd $25, 8($sp) # 8-byte Folded Spill
429; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 16
430; MIPS64R6O0-NEXT:    jrc $ra
431;
432; O1-LABEL: AtomicLoadAnd:
433; O1:       # %bb.0: # %entry
434; O1-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAnd)))
435; O1-NEXT:    daddu $1, $1, $25
436; O1-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAnd)))
437; O1-NEXT:    ld $1, %got_disp(x)($1)
438; O1-NEXT:  .LBB2_1: # %entry
439; O1-NEXT:    # =>This Inner Loop Header: Depth=1
440; O1-NEXT:    lld $2, 0($1)
441; O1-NEXT:    and $3, $2, $4
442; O1-NEXT:    scd $3, 0($1)
443; O1-NEXT:    beqz $3, .LBB2_1
444; O1-NEXT:    nop
445; O1-NEXT:  # %bb.2: # %entry
446; O1-NEXT:    jr $ra
447; O1-NEXT:    nop
448;
449; O2-LABEL: AtomicLoadAnd:
450; O2:       # %bb.0: # %entry
451; O2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAnd)))
452; O2-NEXT:    daddu $1, $1, $25
453; O2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAnd)))
454; O2-NEXT:    ld $1, %got_disp(x)($1)
455; O2-NEXT:  .LBB2_1: # %entry
456; O2-NEXT:    # =>This Inner Loop Header: Depth=1
457; O2-NEXT:    lld $2, 0($1)
458; O2-NEXT:    and $3, $2, $4
459; O2-NEXT:    scd $3, 0($1)
460; O2-NEXT:    beqz $3, .LBB2_1
461; O2-NEXT:    nop
462; O2-NEXT:  # %bb.2: # %entry
463; O2-NEXT:    jr $ra
464; O2-NEXT:    nop
465;
466; O3-LABEL: AtomicLoadAnd:
467; O3:       # %bb.0: # %entry
468; O3-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAnd)))
469; O3-NEXT:    daddu $1, $1, $25
470; O3-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAnd)))
471; O3-NEXT:    ld $1, %got_disp(x)($1)
472; O3-NEXT:  .LBB2_1: # %entry
473; O3-NEXT:    # =>This Inner Loop Header: Depth=1
474; O3-NEXT:    lld $2, 0($1)
475; O3-NEXT:    and $3, $2, $4
476; O3-NEXT:    scd $3, 0($1)
477; O3-NEXT:    beqz $3, .LBB2_1
478; O3-NEXT:    nop
479; O3-NEXT:  # %bb.2: # %entry
480; O3-NEXT:    jr $ra
481; O3-NEXT:    nop
482;
483; MIPS64EB-LABEL: AtomicLoadAnd:
484; MIPS64EB:       # %bb.0: # %entry
485; MIPS64EB-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAnd)))
486; MIPS64EB-NEXT:    daddu $1, $1, $25
487; MIPS64EB-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAnd)))
488; MIPS64EB-NEXT:    ld $1, %got_disp(x)($1)
489; MIPS64EB-NEXT:  .LBB2_1: # %entry
490; MIPS64EB-NEXT:    # =>This Inner Loop Header: Depth=1
491; MIPS64EB-NEXT:    lld $2, 0($1)
492; MIPS64EB-NEXT:    and $3, $2, $4
493; MIPS64EB-NEXT:    scd $3, 0($1)
494; MIPS64EB-NEXT:    beqz $3, .LBB2_1
495; MIPS64EB-NEXT:    nop
496; MIPS64EB-NEXT:  # %bb.2: # %entry
497; MIPS64EB-NEXT:    jr $ra
498; MIPS64EB-NEXT:    nop
499entry:
500  %0 = atomicrmw and i64* @x, i64 %incr monotonic
501  ret i64 %0
502
503}
504
505define i64 @AtomicLoadOr(i64 signext %incr) nounwind {
506; MIPS4-LABEL: AtomicLoadOr:
507; MIPS4:       # %bb.0: # %entry
508; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadOr)))
509; MIPS4-NEXT:    daddu $1, $1, $25
510; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadOr)))
511; MIPS4-NEXT:    ld $1, %got_disp(x)($1)
512; MIPS4-NEXT:  .LBB3_1: # %entry
513; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
514; MIPS4-NEXT:    lld $2, 0($1)
515; MIPS4-NEXT:    or $3, $2, $4
516; MIPS4-NEXT:    scd $3, 0($1)
517; MIPS4-NEXT:    beqz $3, .LBB3_1
518; MIPS4-NEXT:    nop
519; MIPS4-NEXT:  # %bb.2: # %entry
520; MIPS4-NEXT:    jr $ra
521; MIPS4-NEXT:    nop
522;
523; MIPS64-LABEL: AtomicLoadOr:
524; MIPS64:       # %bb.0: # %entry
525; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadOr)))
526; MIPS64-NEXT:    daddu $1, $1, $25
527; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadOr)))
528; MIPS64-NEXT:    ld $1, %got_disp(x)($1)
529; MIPS64-NEXT:  .LBB3_1: # %entry
530; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
531; MIPS64-NEXT:    lld $2, 0($1)
532; MIPS64-NEXT:    or $3, $2, $4
533; MIPS64-NEXT:    scd $3, 0($1)
534; MIPS64-NEXT:    beqz $3, .LBB3_1
535; MIPS64-NEXT:    nop
536; MIPS64-NEXT:  # %bb.2: # %entry
537; MIPS64-NEXT:    jr $ra
538; MIPS64-NEXT:    nop
539;
540; MIPS64R2-LABEL: AtomicLoadOr:
541; MIPS64R2:       # %bb.0: # %entry
542; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadOr)))
543; MIPS64R2-NEXT:    daddu $1, $1, $25
544; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadOr)))
545; MIPS64R2-NEXT:    ld $1, %got_disp(x)($1)
546; MIPS64R2-NEXT:  .LBB3_1: # %entry
547; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
548; MIPS64R2-NEXT:    lld $2, 0($1)
549; MIPS64R2-NEXT:    or $3, $2, $4
550; MIPS64R2-NEXT:    scd $3, 0($1)
551; MIPS64R2-NEXT:    beqz $3, .LBB3_1
552; MIPS64R2-NEXT:    nop
553; MIPS64R2-NEXT:  # %bb.2: # %entry
554; MIPS64R2-NEXT:    jr $ra
555; MIPS64R2-NEXT:    nop
556;
557; MIPS64R6-LABEL: AtomicLoadOr:
558; MIPS64R6:       # %bb.0: # %entry
559; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadOr)))
560; MIPS64R6-NEXT:    daddu $1, $1, $25
561; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadOr)))
562; MIPS64R6-NEXT:    ld $1, %got_disp(x)($1)
563; MIPS64R6-NEXT:  .LBB3_1: # %entry
564; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
565; MIPS64R6-NEXT:    lld $2, 0($1)
566; MIPS64R6-NEXT:    or $3, $2, $4
567; MIPS64R6-NEXT:    scd $3, 0($1)
568; MIPS64R6-NEXT:    beqzc $3, .LBB3_1
569; MIPS64R6-NEXT:    nop
570; MIPS64R6-NEXT:  # %bb.2: # %entry
571; MIPS64R6-NEXT:    jrc $ra
572;
573; MIPS64R6O0-LABEL: AtomicLoadOr:
574; MIPS64R6O0:       # %bb.0: # %entry
575; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -16
576; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadOr)))
577; MIPS64R6O0-NEXT:    daddu $1, $1, $25
578; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadOr)))
579; MIPS64R6O0-NEXT:    move $25, $4
580; MIPS64R6O0-NEXT:    ld $1, %got_disp(x)($1)
581; MIPS64R6O0-NEXT:  .LBB3_1: # %entry
582; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
583; MIPS64R6O0-NEXT:    lld $2, 0($1)
584; MIPS64R6O0-NEXT:    or $3, $2, $4
585; MIPS64R6O0-NEXT:    scd $3, 0($1)
586; MIPS64R6O0-NEXT:    beqzc $3, .LBB3_1
587; MIPS64R6O0-NEXT:  # %bb.2: # %entry
588; MIPS64R6O0-NEXT:    sd $25, 8($sp) # 8-byte Folded Spill
589; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 16
590; MIPS64R6O0-NEXT:    jrc $ra
591;
592; O1-LABEL: AtomicLoadOr:
593; O1:       # %bb.0: # %entry
594; O1-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadOr)))
595; O1-NEXT:    daddu $1, $1, $25
596; O1-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadOr)))
597; O1-NEXT:    ld $1, %got_disp(x)($1)
598; O1-NEXT:  .LBB3_1: # %entry
599; O1-NEXT:    # =>This Inner Loop Header: Depth=1
600; O1-NEXT:    lld $2, 0($1)
601; O1-NEXT:    or $3, $2, $4
602; O1-NEXT:    scd $3, 0($1)
603; O1-NEXT:    beqz $3, .LBB3_1
604; O1-NEXT:    nop
605; O1-NEXT:  # %bb.2: # %entry
606; O1-NEXT:    jr $ra
607; O1-NEXT:    nop
608;
609; O2-LABEL: AtomicLoadOr:
610; O2:       # %bb.0: # %entry
611; O2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadOr)))
612; O2-NEXT:    daddu $1, $1, $25
613; O2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadOr)))
614; O2-NEXT:    ld $1, %got_disp(x)($1)
615; O2-NEXT:  .LBB3_1: # %entry
616; O2-NEXT:    # =>This Inner Loop Header: Depth=1
617; O2-NEXT:    lld $2, 0($1)
618; O2-NEXT:    or $3, $2, $4
619; O2-NEXT:    scd $3, 0($1)
620; O2-NEXT:    beqz $3, .LBB3_1
621; O2-NEXT:    nop
622; O2-NEXT:  # %bb.2: # %entry
623; O2-NEXT:    jr $ra
624; O2-NEXT:    nop
625;
626; O3-LABEL: AtomicLoadOr:
627; O3:       # %bb.0: # %entry
628; O3-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadOr)))
629; O3-NEXT:    daddu $1, $1, $25
630; O3-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadOr)))
631; O3-NEXT:    ld $1, %got_disp(x)($1)
632; O3-NEXT:  .LBB3_1: # %entry
633; O3-NEXT:    # =>This Inner Loop Header: Depth=1
634; O3-NEXT:    lld $2, 0($1)
635; O3-NEXT:    or $3, $2, $4
636; O3-NEXT:    scd $3, 0($1)
637; O3-NEXT:    beqz $3, .LBB3_1
638; O3-NEXT:    nop
639; O3-NEXT:  # %bb.2: # %entry
640; O3-NEXT:    jr $ra
641; O3-NEXT:    nop
642;
643; MIPS64EB-LABEL: AtomicLoadOr:
644; MIPS64EB:       # %bb.0: # %entry
645; MIPS64EB-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadOr)))
646; MIPS64EB-NEXT:    daddu $1, $1, $25
647; MIPS64EB-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadOr)))
648; MIPS64EB-NEXT:    ld $1, %got_disp(x)($1)
649; MIPS64EB-NEXT:  .LBB3_1: # %entry
650; MIPS64EB-NEXT:    # =>This Inner Loop Header: Depth=1
651; MIPS64EB-NEXT:    lld $2, 0($1)
652; MIPS64EB-NEXT:    or $3, $2, $4
653; MIPS64EB-NEXT:    scd $3, 0($1)
654; MIPS64EB-NEXT:    beqz $3, .LBB3_1
655; MIPS64EB-NEXT:    nop
656; MIPS64EB-NEXT:  # %bb.2: # %entry
657; MIPS64EB-NEXT:    jr $ra
658; MIPS64EB-NEXT:    nop
659entry:
660  %0 = atomicrmw or i64* @x, i64 %incr monotonic
661  ret i64 %0
662
663}
664
665define i64 @AtomicLoadXor(i64 signext %incr) nounwind {
666; MIPS4-LABEL: AtomicLoadXor:
667; MIPS4:       # %bb.0: # %entry
668; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadXor)))
669; MIPS4-NEXT:    daddu $1, $1, $25
670; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadXor)))
671; MIPS4-NEXT:    ld $1, %got_disp(x)($1)
672; MIPS4-NEXT:  .LBB4_1: # %entry
673; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
674; MIPS4-NEXT:    lld $2, 0($1)
675; MIPS4-NEXT:    xor $3, $2, $4
676; MIPS4-NEXT:    scd $3, 0($1)
677; MIPS4-NEXT:    beqz $3, .LBB4_1
678; MIPS4-NEXT:    nop
679; MIPS4-NEXT:  # %bb.2: # %entry
680; MIPS4-NEXT:    jr $ra
681; MIPS4-NEXT:    nop
682;
683; MIPS64-LABEL: AtomicLoadXor:
684; MIPS64:       # %bb.0: # %entry
685; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadXor)))
686; MIPS64-NEXT:    daddu $1, $1, $25
687; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadXor)))
688; MIPS64-NEXT:    ld $1, %got_disp(x)($1)
689; MIPS64-NEXT:  .LBB4_1: # %entry
690; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
691; MIPS64-NEXT:    lld $2, 0($1)
692; MIPS64-NEXT:    xor $3, $2, $4
693; MIPS64-NEXT:    scd $3, 0($1)
694; MIPS64-NEXT:    beqz $3, .LBB4_1
695; MIPS64-NEXT:    nop
696; MIPS64-NEXT:  # %bb.2: # %entry
697; MIPS64-NEXT:    jr $ra
698; MIPS64-NEXT:    nop
699;
700; MIPS64R2-LABEL: AtomicLoadXor:
701; MIPS64R2:       # %bb.0: # %entry
702; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadXor)))
703; MIPS64R2-NEXT:    daddu $1, $1, $25
704; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadXor)))
705; MIPS64R2-NEXT:    ld $1, %got_disp(x)($1)
706; MIPS64R2-NEXT:  .LBB4_1: # %entry
707; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
708; MIPS64R2-NEXT:    lld $2, 0($1)
709; MIPS64R2-NEXT:    xor $3, $2, $4
710; MIPS64R2-NEXT:    scd $3, 0($1)
711; MIPS64R2-NEXT:    beqz $3, .LBB4_1
712; MIPS64R2-NEXT:    nop
713; MIPS64R2-NEXT:  # %bb.2: # %entry
714; MIPS64R2-NEXT:    jr $ra
715; MIPS64R2-NEXT:    nop
716;
717; MIPS64R6-LABEL: AtomicLoadXor:
718; MIPS64R6:       # %bb.0: # %entry
719; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadXor)))
720; MIPS64R6-NEXT:    daddu $1, $1, $25
721; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadXor)))
722; MIPS64R6-NEXT:    ld $1, %got_disp(x)($1)
723; MIPS64R6-NEXT:  .LBB4_1: # %entry
724; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
725; MIPS64R6-NEXT:    lld $2, 0($1)
726; MIPS64R6-NEXT:    xor $3, $2, $4
727; MIPS64R6-NEXT:    scd $3, 0($1)
728; MIPS64R6-NEXT:    beqzc $3, .LBB4_1
729; MIPS64R6-NEXT:    nop
730; MIPS64R6-NEXT:  # %bb.2: # %entry
731; MIPS64R6-NEXT:    jrc $ra
732;
733; MIPS64R6O0-LABEL: AtomicLoadXor:
734; MIPS64R6O0:       # %bb.0: # %entry
735; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -16
736; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadXor)))
737; MIPS64R6O0-NEXT:    daddu $1, $1, $25
738; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadXor)))
739; MIPS64R6O0-NEXT:    move $25, $4
740; MIPS64R6O0-NEXT:    ld $1, %got_disp(x)($1)
741; MIPS64R6O0-NEXT:  .LBB4_1: # %entry
742; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
743; MIPS64R6O0-NEXT:    lld $2, 0($1)
744; MIPS64R6O0-NEXT:    xor $3, $2, $4
745; MIPS64R6O0-NEXT:    scd $3, 0($1)
746; MIPS64R6O0-NEXT:    beqzc $3, .LBB4_1
747; MIPS64R6O0-NEXT:  # %bb.2: # %entry
748; MIPS64R6O0-NEXT:    sd $25, 8($sp) # 8-byte Folded Spill
749; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 16
750; MIPS64R6O0-NEXT:    jrc $ra
751;
752; O1-LABEL: AtomicLoadXor:
753; O1:       # %bb.0: # %entry
754; O1-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadXor)))
755; O1-NEXT:    daddu $1, $1, $25
756; O1-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadXor)))
757; O1-NEXT:    ld $1, %got_disp(x)($1)
758; O1-NEXT:  .LBB4_1: # %entry
759; O1-NEXT:    # =>This Inner Loop Header: Depth=1
760; O1-NEXT:    lld $2, 0($1)
761; O1-NEXT:    xor $3, $2, $4
762; O1-NEXT:    scd $3, 0($1)
763; O1-NEXT:    beqz $3, .LBB4_1
764; O1-NEXT:    nop
765; O1-NEXT:  # %bb.2: # %entry
766; O1-NEXT:    jr $ra
767; O1-NEXT:    nop
768;
769; O2-LABEL: AtomicLoadXor:
770; O2:       # %bb.0: # %entry
771; O2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadXor)))
772; O2-NEXT:    daddu $1, $1, $25
773; O2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadXor)))
774; O2-NEXT:    ld $1, %got_disp(x)($1)
775; O2-NEXT:  .LBB4_1: # %entry
776; O2-NEXT:    # =>This Inner Loop Header: Depth=1
777; O2-NEXT:    lld $2, 0($1)
778; O2-NEXT:    xor $3, $2, $4
779; O2-NEXT:    scd $3, 0($1)
780; O2-NEXT:    beqz $3, .LBB4_1
781; O2-NEXT:    nop
782; O2-NEXT:  # %bb.2: # %entry
783; O2-NEXT:    jr $ra
784; O2-NEXT:    nop
785;
786; O3-LABEL: AtomicLoadXor:
787; O3:       # %bb.0: # %entry
788; O3-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadXor)))
789; O3-NEXT:    daddu $1, $1, $25
790; O3-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadXor)))
791; O3-NEXT:    ld $1, %got_disp(x)($1)
792; O3-NEXT:  .LBB4_1: # %entry
793; O3-NEXT:    # =>This Inner Loop Header: Depth=1
794; O3-NEXT:    lld $2, 0($1)
795; O3-NEXT:    xor $3, $2, $4
796; O3-NEXT:    scd $3, 0($1)
797; O3-NEXT:    beqz $3, .LBB4_1
798; O3-NEXT:    nop
799; O3-NEXT:  # %bb.2: # %entry
800; O3-NEXT:    jr $ra
801; O3-NEXT:    nop
802;
803; MIPS64EB-LABEL: AtomicLoadXor:
804; MIPS64EB:       # %bb.0: # %entry
805; MIPS64EB-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadXor)))
806; MIPS64EB-NEXT:    daddu $1, $1, $25
807; MIPS64EB-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadXor)))
808; MIPS64EB-NEXT:    ld $1, %got_disp(x)($1)
809; MIPS64EB-NEXT:  .LBB4_1: # %entry
810; MIPS64EB-NEXT:    # =>This Inner Loop Header: Depth=1
811; MIPS64EB-NEXT:    lld $2, 0($1)
812; MIPS64EB-NEXT:    xor $3, $2, $4
813; MIPS64EB-NEXT:    scd $3, 0($1)
814; MIPS64EB-NEXT:    beqz $3, .LBB4_1
815; MIPS64EB-NEXT:    nop
816; MIPS64EB-NEXT:  # %bb.2: # %entry
817; MIPS64EB-NEXT:    jr $ra
818; MIPS64EB-NEXT:    nop
819entry:
820  %0 = atomicrmw xor i64* @x, i64 %incr monotonic
821  ret i64 %0
822
823}
824
825define i64 @AtomicLoadNand(i64 signext %incr) nounwind {
826; MIPS4-LABEL: AtomicLoadNand:
827; MIPS4:       # %bb.0: # %entry
828; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand)))
829; MIPS4-NEXT:    daddu $1, $1, $25
830; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand)))
831; MIPS4-NEXT:    ld $1, %got_disp(x)($1)
832; MIPS4-NEXT:  .LBB5_1: # %entry
833; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
834; MIPS4-NEXT:    lld $2, 0($1)
835; MIPS4-NEXT:    and $3, $2, $4
836; MIPS4-NEXT:    nor $3, $zero, $3
837; MIPS4-NEXT:    scd $3, 0($1)
838; MIPS4-NEXT:    beqz $3, .LBB5_1
839; MIPS4-NEXT:    nop
840; MIPS4-NEXT:  # %bb.2: # %entry
841; MIPS4-NEXT:    jr $ra
842; MIPS4-NEXT:    nop
843;
844; MIPS64-LABEL: AtomicLoadNand:
845; MIPS64:       # %bb.0: # %entry
846; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand)))
847; MIPS64-NEXT:    daddu $1, $1, $25
848; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand)))
849; MIPS64-NEXT:    ld $1, %got_disp(x)($1)
850; MIPS64-NEXT:  .LBB5_1: # %entry
851; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
852; MIPS64-NEXT:    lld $2, 0($1)
853; MIPS64-NEXT:    and $3, $2, $4
854; MIPS64-NEXT:    nor $3, $zero, $3
855; MIPS64-NEXT:    scd $3, 0($1)
856; MIPS64-NEXT:    beqz $3, .LBB5_1
857; MIPS64-NEXT:    nop
858; MIPS64-NEXT:  # %bb.2: # %entry
859; MIPS64-NEXT:    jr $ra
860; MIPS64-NEXT:    nop
861;
862; MIPS64R2-LABEL: AtomicLoadNand:
863; MIPS64R2:       # %bb.0: # %entry
864; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand)))
865; MIPS64R2-NEXT:    daddu $1, $1, $25
866; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand)))
867; MIPS64R2-NEXT:    ld $1, %got_disp(x)($1)
868; MIPS64R2-NEXT:  .LBB5_1: # %entry
869; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
870; MIPS64R2-NEXT:    lld $2, 0($1)
871; MIPS64R2-NEXT:    and $3, $2, $4
872; MIPS64R2-NEXT:    nor $3, $zero, $3
873; MIPS64R2-NEXT:    scd $3, 0($1)
874; MIPS64R2-NEXT:    beqz $3, .LBB5_1
875; MIPS64R2-NEXT:    nop
876; MIPS64R2-NEXT:  # %bb.2: # %entry
877; MIPS64R2-NEXT:    jr $ra
878; MIPS64R2-NEXT:    nop
879;
880; MIPS64R6-LABEL: AtomicLoadNand:
881; MIPS64R6:       # %bb.0: # %entry
882; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand)))
883; MIPS64R6-NEXT:    daddu $1, $1, $25
884; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand)))
885; MIPS64R6-NEXT:    ld $1, %got_disp(x)($1)
886; MIPS64R6-NEXT:  .LBB5_1: # %entry
887; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
888; MIPS64R6-NEXT:    lld $2, 0($1)
889; MIPS64R6-NEXT:    and $3, $2, $4
890; MIPS64R6-NEXT:    nor $3, $zero, $3
891; MIPS64R6-NEXT:    scd $3, 0($1)
892; MIPS64R6-NEXT:    beqzc $3, .LBB5_1
893; MIPS64R6-NEXT:    nop
894; MIPS64R6-NEXT:  # %bb.2: # %entry
895; MIPS64R6-NEXT:    jrc $ra
896;
897; MIPS64R6O0-LABEL: AtomicLoadNand:
898; MIPS64R6O0:       # %bb.0: # %entry
899; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -16
900; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand)))
901; MIPS64R6O0-NEXT:    daddu $1, $1, $25
902; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand)))
903; MIPS64R6O0-NEXT:    move $25, $4
904; MIPS64R6O0-NEXT:    ld $1, %got_disp(x)($1)
905; MIPS64R6O0-NEXT:  .LBB5_1: # %entry
906; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
907; MIPS64R6O0-NEXT:    lld $2, 0($1)
908; MIPS64R6O0-NEXT:    and $3, $2, $4
909; MIPS64R6O0-NEXT:    nor $3, $zero, $3
910; MIPS64R6O0-NEXT:    scd $3, 0($1)
911; MIPS64R6O0-NEXT:    beqzc $3, .LBB5_1
912; MIPS64R6O0-NEXT:  # %bb.2: # %entry
913; MIPS64R6O0-NEXT:    sd $25, 8($sp) # 8-byte Folded Spill
914; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 16
915; MIPS64R6O0-NEXT:    jrc $ra
916;
917; O1-LABEL: AtomicLoadNand:
918; O1:       # %bb.0: # %entry
919; O1-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand)))
920; O1-NEXT:    daddu $1, $1, $25
921; O1-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand)))
922; O1-NEXT:    ld $1, %got_disp(x)($1)
923; O1-NEXT:  .LBB5_1: # %entry
924; O1-NEXT:    # =>This Inner Loop Header: Depth=1
925; O1-NEXT:    lld $2, 0($1)
926; O1-NEXT:    and $3, $2, $4
927; O1-NEXT:    nor $3, $zero, $3
928; O1-NEXT:    scd $3, 0($1)
929; O1-NEXT:    beqz $3, .LBB5_1
930; O1-NEXT:    nop
931; O1-NEXT:  # %bb.2: # %entry
932; O1-NEXT:    jr $ra
933; O1-NEXT:    nop
934;
935; O2-LABEL: AtomicLoadNand:
936; O2:       # %bb.0: # %entry
937; O2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand)))
938; O2-NEXT:    daddu $1, $1, $25
939; O2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand)))
940; O2-NEXT:    ld $1, %got_disp(x)($1)
941; O2-NEXT:  .LBB5_1: # %entry
942; O2-NEXT:    # =>This Inner Loop Header: Depth=1
943; O2-NEXT:    lld $2, 0($1)
944; O2-NEXT:    and $3, $2, $4
945; O2-NEXT:    nor $3, $zero, $3
946; O2-NEXT:    scd $3, 0($1)
947; O2-NEXT:    beqz $3, .LBB5_1
948; O2-NEXT:    nop
949; O2-NEXT:  # %bb.2: # %entry
950; O2-NEXT:    jr $ra
951; O2-NEXT:    nop
952;
953; O3-LABEL: AtomicLoadNand:
954; O3:       # %bb.0: # %entry
955; O3-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand)))
956; O3-NEXT:    daddu $1, $1, $25
957; O3-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand)))
958; O3-NEXT:    ld $1, %got_disp(x)($1)
959; O3-NEXT:  .LBB5_1: # %entry
960; O3-NEXT:    # =>This Inner Loop Header: Depth=1
961; O3-NEXT:    lld $2, 0($1)
962; O3-NEXT:    and $3, $2, $4
963; O3-NEXT:    nor $3, $zero, $3
964; O3-NEXT:    scd $3, 0($1)
965; O3-NEXT:    beqz $3, .LBB5_1
966; O3-NEXT:    nop
967; O3-NEXT:  # %bb.2: # %entry
968; O3-NEXT:    jr $ra
969; O3-NEXT:    nop
970;
971; MIPS64EB-LABEL: AtomicLoadNand:
972; MIPS64EB:       # %bb.0: # %entry
973; MIPS64EB-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand)))
974; MIPS64EB-NEXT:    daddu $1, $1, $25
975; MIPS64EB-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand)))
976; MIPS64EB-NEXT:    ld $1, %got_disp(x)($1)
977; MIPS64EB-NEXT:  .LBB5_1: # %entry
978; MIPS64EB-NEXT:    # =>This Inner Loop Header: Depth=1
979; MIPS64EB-NEXT:    lld $2, 0($1)
980; MIPS64EB-NEXT:    and $3, $2, $4
981; MIPS64EB-NEXT:    nor $3, $zero, $3
982; MIPS64EB-NEXT:    scd $3, 0($1)
983; MIPS64EB-NEXT:    beqz $3, .LBB5_1
984; MIPS64EB-NEXT:    nop
985; MIPS64EB-NEXT:  # %bb.2: # %entry
986; MIPS64EB-NEXT:    jr $ra
987; MIPS64EB-NEXT:    nop
988entry:
989  %0 = atomicrmw nand i64* @x, i64 %incr monotonic
990  ret i64 %0
991
992}
993
994define i64 @AtomicSwap64(i64 signext %newval) nounwind {
995; MIPS4-LABEL: AtomicSwap64:
996; MIPS4:       # %bb.0: # %entry
997; MIPS4-NEXT:    daddiu $sp, $sp, -16
998; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap64)))
999; MIPS4-NEXT:    daddu $1, $1, $25
1000; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap64)))
1001; MIPS4-NEXT:    sd $4, 8($sp)
1002; MIPS4-NEXT:    ld $1, %got_disp(x)($1)
1003; MIPS4-NEXT:  .LBB6_1: # %entry
1004; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
1005; MIPS4-NEXT:    lld $2, 0($1)
1006; MIPS4-NEXT:    move $3, $4
1007; MIPS4-NEXT:    scd $3, 0($1)
1008; MIPS4-NEXT:    beqz $3, .LBB6_1
1009; MIPS4-NEXT:    nop
1010; MIPS4-NEXT:  # %bb.2: # %entry
1011; MIPS4-NEXT:    jr $ra
1012; MIPS4-NEXT:    daddiu $sp, $sp, 16
1013;
1014; MIPS64-LABEL: AtomicSwap64:
1015; MIPS64:       # %bb.0: # %entry
1016; MIPS64-NEXT:    daddiu $sp, $sp, -16
1017; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap64)))
1018; MIPS64-NEXT:    daddu $1, $1, $25
1019; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap64)))
1020; MIPS64-NEXT:    sd $4, 8($sp)
1021; MIPS64-NEXT:    ld $1, %got_disp(x)($1)
1022; MIPS64-NEXT:  .LBB6_1: # %entry
1023; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
1024; MIPS64-NEXT:    lld $2, 0($1)
1025; MIPS64-NEXT:    move $3, $4
1026; MIPS64-NEXT:    scd $3, 0($1)
1027; MIPS64-NEXT:    beqz $3, .LBB6_1
1028; MIPS64-NEXT:    nop
1029; MIPS64-NEXT:  # %bb.2: # %entry
1030; MIPS64-NEXT:    jr $ra
1031; MIPS64-NEXT:    daddiu $sp, $sp, 16
1032;
1033; MIPS64R2-LABEL: AtomicSwap64:
1034; MIPS64R2:       # %bb.0: # %entry
1035; MIPS64R2-NEXT:    daddiu $sp, $sp, -16
1036; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap64)))
1037; MIPS64R2-NEXT:    daddu $1, $1, $25
1038; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap64)))
1039; MIPS64R2-NEXT:    sd $4, 8($sp)
1040; MIPS64R2-NEXT:    ld $1, %got_disp(x)($1)
1041; MIPS64R2-NEXT:  .LBB6_1: # %entry
1042; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
1043; MIPS64R2-NEXT:    lld $2, 0($1)
1044; MIPS64R2-NEXT:    move $3, $4
1045; MIPS64R2-NEXT:    scd $3, 0($1)
1046; MIPS64R2-NEXT:    beqz $3, .LBB6_1
1047; MIPS64R2-NEXT:    nop
1048; MIPS64R2-NEXT:  # %bb.2: # %entry
1049; MIPS64R2-NEXT:    jr $ra
1050; MIPS64R2-NEXT:    daddiu $sp, $sp, 16
1051;
1052; MIPS64R6-LABEL: AtomicSwap64:
1053; MIPS64R6:       # %bb.0: # %entry
1054; MIPS64R6-NEXT:    daddiu $sp, $sp, -16
1055; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap64)))
1056; MIPS64R6-NEXT:    daddu $1, $1, $25
1057; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap64)))
1058; MIPS64R6-NEXT:    sd $4, 8($sp)
1059; MIPS64R6-NEXT:    ld $1, %got_disp(x)($1)
1060; MIPS64R6-NEXT:  .LBB6_1: # %entry
1061; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
1062; MIPS64R6-NEXT:    lld $2, 0($1)
1063; MIPS64R6-NEXT:    move $3, $4
1064; MIPS64R6-NEXT:    scd $3, 0($1)
1065; MIPS64R6-NEXT:    beqzc $3, .LBB6_1
1066; MIPS64R6-NEXT:    nop
1067; MIPS64R6-NEXT:  # %bb.2: # %entry
1068; MIPS64R6-NEXT:    jr $ra
1069; MIPS64R6-NEXT:    daddiu $sp, $sp, 16
1070;
1071; MIPS64R6O0-LABEL: AtomicSwap64:
1072; MIPS64R6O0:       # %bb.0: # %entry
1073; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -16
1074; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap64)))
1075; MIPS64R6O0-NEXT:    daddu $1, $1, $25
1076; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap64)))
1077; MIPS64R6O0-NEXT:    move $25, $4
1078; MIPS64R6O0-NEXT:    sd $4, 8($sp)
1079; MIPS64R6O0-NEXT:    ld $4, 8($sp)
1080; MIPS64R6O0-NEXT:    ld $1, %got_disp(x)($1)
1081; MIPS64R6O0-NEXT:  .LBB6_1: # %entry
1082; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
1083; MIPS64R6O0-NEXT:    lld $2, 0($1)
1084; MIPS64R6O0-NEXT:    move $3, $4
1085; MIPS64R6O0-NEXT:    scd $3, 0($1)
1086; MIPS64R6O0-NEXT:    beqzc $3, .LBB6_1
1087; MIPS64R6O0-NEXT:  # %bb.2: # %entry
1088; MIPS64R6O0-NEXT:    sd $25, 0($sp) # 8-byte Folded Spill
1089; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 16
1090; MIPS64R6O0-NEXT:    jrc $ra
1091;
1092; O1-LABEL: AtomicSwap64:
1093; O1:       # %bb.0: # %entry
1094; O1-NEXT:    daddiu $sp, $sp, -16
1095; O1-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap64)))
1096; O1-NEXT:    daddu $1, $1, $25
1097; O1-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap64)))
1098; O1-NEXT:    sd $4, 8($sp)
1099; O1-NEXT:    ld $1, %got_disp(x)($1)
1100; O1-NEXT:  .LBB6_1: # %entry
1101; O1-NEXT:    # =>This Inner Loop Header: Depth=1
1102; O1-NEXT:    lld $2, 0($1)
1103; O1-NEXT:    move $3, $4
1104; O1-NEXT:    scd $3, 0($1)
1105; O1-NEXT:    beqz $3, .LBB6_1
1106; O1-NEXT:    nop
1107; O1-NEXT:  # %bb.2: # %entry
1108; O1-NEXT:    jr $ra
1109; O1-NEXT:    daddiu $sp, $sp, 16
1110;
1111; O2-LABEL: AtomicSwap64:
1112; O2:       # %bb.0: # %entry
1113; O2-NEXT:    daddiu $sp, $sp, -16
1114; O2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap64)))
1115; O2-NEXT:    daddu $1, $1, $25
1116; O2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap64)))
1117; O2-NEXT:    sd $4, 8($sp)
1118; O2-NEXT:    ld $1, %got_disp(x)($1)
1119; O2-NEXT:  .LBB6_1: # %entry
1120; O2-NEXT:    # =>This Inner Loop Header: Depth=1
1121; O2-NEXT:    lld $2, 0($1)
1122; O2-NEXT:    move $3, $4
1123; O2-NEXT:    scd $3, 0($1)
1124; O2-NEXT:    beqz $3, .LBB6_1
1125; O2-NEXT:    nop
1126; O2-NEXT:  # %bb.2: # %entry
1127; O2-NEXT:    jr $ra
1128; O2-NEXT:    daddiu $sp, $sp, 16
1129;
1130; O3-LABEL: AtomicSwap64:
1131; O3:       # %bb.0: # %entry
1132; O3-NEXT:    daddiu $sp, $sp, -16
1133; O3-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap64)))
1134; O3-NEXT:    sd $4, 8($sp)
1135; O3-NEXT:    daddu $1, $1, $25
1136; O3-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap64)))
1137; O3-NEXT:    ld $1, %got_disp(x)($1)
1138; O3-NEXT:  .LBB6_1: # %entry
1139; O3-NEXT:    # =>This Inner Loop Header: Depth=1
1140; O3-NEXT:    lld $2, 0($1)
1141; O3-NEXT:    move $3, $4
1142; O3-NEXT:    scd $3, 0($1)
1143; O3-NEXT:    beqz $3, .LBB6_1
1144; O3-NEXT:    nop
1145; O3-NEXT:  # %bb.2: # %entry
1146; O3-NEXT:    jr $ra
1147; O3-NEXT:    daddiu $sp, $sp, 16
1148;
1149; MIPS64EB-LABEL: AtomicSwap64:
1150; MIPS64EB:       # %bb.0: # %entry
1151; MIPS64EB-NEXT:    daddiu $sp, $sp, -16
1152; MIPS64EB-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap64)))
1153; MIPS64EB-NEXT:    daddu $1, $1, $25
1154; MIPS64EB-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap64)))
1155; MIPS64EB-NEXT:    sd $4, 8($sp)
1156; MIPS64EB-NEXT:    ld $1, %got_disp(x)($1)
1157; MIPS64EB-NEXT:  .LBB6_1: # %entry
1158; MIPS64EB-NEXT:    # =>This Inner Loop Header: Depth=1
1159; MIPS64EB-NEXT:    lld $2, 0($1)
1160; MIPS64EB-NEXT:    move $3, $4
1161; MIPS64EB-NEXT:    scd $3, 0($1)
1162; MIPS64EB-NEXT:    beqz $3, .LBB6_1
1163; MIPS64EB-NEXT:    nop
1164; MIPS64EB-NEXT:  # %bb.2: # %entry
1165; MIPS64EB-NEXT:    jr $ra
1166; MIPS64EB-NEXT:    daddiu $sp, $sp, 16
1167entry:
1168  %newval.addr = alloca i64, align 4
1169  store i64 %newval, i64* %newval.addr, align 4
1170  %tmp = load i64, i64* %newval.addr, align 4
1171  %0 = atomicrmw xchg i64* @x, i64 %tmp monotonic
1172  ret i64 %0
1173
1174}
1175
1176define i64 @AtomicCmpSwap64(i64 signext %oldval, i64 signext %newval) nounwind {
1177; MIPS4-LABEL: AtomicCmpSwap64:
1178; MIPS4:       # %bb.0: # %entry
1179; MIPS4-NEXT:    daddiu $sp, $sp, -16
1180; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap64)))
1181; MIPS4-NEXT:    daddu $1, $1, $25
1182; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap64)))
1183; MIPS4-NEXT:    sd $5, 8($sp)
1184; MIPS4-NEXT:    ld $1, %got_disp(x)($1)
1185; MIPS4-NEXT:  .LBB7_1: # %entry
1186; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
1187; MIPS4-NEXT:    lld $2, 0($1)
1188; MIPS4-NEXT:    bne $2, $4, .LBB7_3
1189; MIPS4-NEXT:    nop
1190; MIPS4-NEXT:  # %bb.2: # %entry
1191; MIPS4-NEXT:    # in Loop: Header=BB7_1 Depth=1
1192; MIPS4-NEXT:    move $3, $5
1193; MIPS4-NEXT:    scd $3, 0($1)
1194; MIPS4-NEXT:    beqz $3, .LBB7_1
1195; MIPS4-NEXT:    nop
1196; MIPS4-NEXT:  .LBB7_3: # %entry
1197; MIPS4-NEXT:    jr $ra
1198; MIPS4-NEXT:    daddiu $sp, $sp, 16
1199;
1200; MIPS64-LABEL: AtomicCmpSwap64:
1201; MIPS64:       # %bb.0: # %entry
1202; MIPS64-NEXT:    daddiu $sp, $sp, -16
1203; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap64)))
1204; MIPS64-NEXT:    daddu $1, $1, $25
1205; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap64)))
1206; MIPS64-NEXT:    sd $5, 8($sp)
1207; MIPS64-NEXT:    ld $1, %got_disp(x)($1)
1208; MIPS64-NEXT:  .LBB7_1: # %entry
1209; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
1210; MIPS64-NEXT:    lld $2, 0($1)
1211; MIPS64-NEXT:    bne $2, $4, .LBB7_3
1212; MIPS64-NEXT:    nop
1213; MIPS64-NEXT:  # %bb.2: # %entry
1214; MIPS64-NEXT:    # in Loop: Header=BB7_1 Depth=1
1215; MIPS64-NEXT:    move $3, $5
1216; MIPS64-NEXT:    scd $3, 0($1)
1217; MIPS64-NEXT:    beqz $3, .LBB7_1
1218; MIPS64-NEXT:    nop
1219; MIPS64-NEXT:  .LBB7_3: # %entry
1220; MIPS64-NEXT:    jr $ra
1221; MIPS64-NEXT:    daddiu $sp, $sp, 16
1222;
1223; MIPS64R2-LABEL: AtomicCmpSwap64:
1224; MIPS64R2:       # %bb.0: # %entry
1225; MIPS64R2-NEXT:    daddiu $sp, $sp, -16
1226; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap64)))
1227; MIPS64R2-NEXT:    daddu $1, $1, $25
1228; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap64)))
1229; MIPS64R2-NEXT:    sd $5, 8($sp)
1230; MIPS64R2-NEXT:    ld $1, %got_disp(x)($1)
1231; MIPS64R2-NEXT:  .LBB7_1: # %entry
1232; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
1233; MIPS64R2-NEXT:    lld $2, 0($1)
1234; MIPS64R2-NEXT:    bne $2, $4, .LBB7_3
1235; MIPS64R2-NEXT:    nop
1236; MIPS64R2-NEXT:  # %bb.2: # %entry
1237; MIPS64R2-NEXT:    # in Loop: Header=BB7_1 Depth=1
1238; MIPS64R2-NEXT:    move $3, $5
1239; MIPS64R2-NEXT:    scd $3, 0($1)
1240; MIPS64R2-NEXT:    beqz $3, .LBB7_1
1241; MIPS64R2-NEXT:    nop
1242; MIPS64R2-NEXT:  .LBB7_3: # %entry
1243; MIPS64R2-NEXT:    jr $ra
1244; MIPS64R2-NEXT:    daddiu $sp, $sp, 16
1245;
1246; MIPS64R6-LABEL: AtomicCmpSwap64:
1247; MIPS64R6:       # %bb.0: # %entry
1248; MIPS64R6-NEXT:    daddiu $sp, $sp, -16
1249; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap64)))
1250; MIPS64R6-NEXT:    daddu $1, $1, $25
1251; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap64)))
1252; MIPS64R6-NEXT:    sd $5, 8($sp)
1253; MIPS64R6-NEXT:    ld $1, %got_disp(x)($1)
1254; MIPS64R6-NEXT:  .LBB7_1: # %entry
1255; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
1256; MIPS64R6-NEXT:    lld $2, 0($1)
1257; MIPS64R6-NEXT:    bnec $2, $4, .LBB7_3
1258; MIPS64R6-NEXT:  # %bb.2: # %entry
1259; MIPS64R6-NEXT:    # in Loop: Header=BB7_1 Depth=1
1260; MIPS64R6-NEXT:    move $3, $5
1261; MIPS64R6-NEXT:    scd $3, 0($1)
1262; MIPS64R6-NEXT:    beqzc $3, .LBB7_1
1263; MIPS64R6-NEXT:    nop
1264; MIPS64R6-NEXT:  .LBB7_3: # %entry
1265; MIPS64R6-NEXT:    jr $ra
1266; MIPS64R6-NEXT:    daddiu $sp, $sp, 16
1267;
1268; MIPS64R6O0-LABEL: AtomicCmpSwap64:
1269; MIPS64R6O0:       # %bb.0: # %entry
1270; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -48
1271; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap64)))
1272; MIPS64R6O0-NEXT:    daddu $1, $1, $25
1273; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap64)))
1274; MIPS64R6O0-NEXT:    move $25, $5
1275; MIPS64R6O0-NEXT:    move $2, $4
1276; MIPS64R6O0-NEXT:    sd $5, 40($sp)
1277; MIPS64R6O0-NEXT:    ld $5, 40($sp)
1278; MIPS64R6O0-NEXT:    ld $1, %got_disp(x)($1)
1279; MIPS64R6O0-NEXT:    ld $3, 32($sp) # 8-byte Folded Reload
1280; MIPS64R6O0-NEXT:  .LBB7_1: # %entry
1281; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
1282; MIPS64R6O0-NEXT:    lld $6, 0($1)
1283; MIPS64R6O0-NEXT:    bnec $6, $4, .LBB7_3
1284; MIPS64R6O0-NEXT:  # %bb.2: # %entry
1285; MIPS64R6O0-NEXT:    # in Loop: Header=BB7_1 Depth=1
1286; MIPS64R6O0-NEXT:    move $7, $5
1287; MIPS64R6O0-NEXT:    scd $7, 0($1)
1288; MIPS64R6O0-NEXT:    beqzc $7, .LBB7_1
1289; MIPS64R6O0-NEXT:  .LBB7_3: # %entry
1290; MIPS64R6O0-NEXT:    sd $2, 24($sp) # 8-byte Folded Spill
1291; MIPS64R6O0-NEXT:    move $2, $6
1292; MIPS64R6O0-NEXT:    sd $6, 32($sp) # 8-byte Folded Spill
1293; MIPS64R6O0-NEXT:    sd $25, 16($sp) # 8-byte Folded Spill
1294; MIPS64R6O0-NEXT:    sd $3, 8($sp) # 8-byte Folded Spill
1295; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 48
1296; MIPS64R6O0-NEXT:    jrc $ra
1297;
1298; O1-LABEL: AtomicCmpSwap64:
1299; O1:       # %bb.0: # %entry
1300; O1-NEXT:    daddiu $sp, $sp, -16
1301; O1-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap64)))
1302; O1-NEXT:    daddu $1, $1, $25
1303; O1-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap64)))
1304; O1-NEXT:    sd $5, 8($sp)
1305; O1-NEXT:    ld $1, %got_disp(x)($1)
1306; O1-NEXT:  .LBB7_1: # %entry
1307; O1-NEXT:    # =>This Inner Loop Header: Depth=1
1308; O1-NEXT:    lld $2, 0($1)
1309; O1-NEXT:    bne $2, $4, .LBB7_3
1310; O1-NEXT:    nop
1311; O1-NEXT:  # %bb.2: # %entry
1312; O1-NEXT:    # in Loop: Header=BB7_1 Depth=1
1313; O1-NEXT:    move $3, $5
1314; O1-NEXT:    scd $3, 0($1)
1315; O1-NEXT:    beqz $3, .LBB7_1
1316; O1-NEXT:    nop
1317; O1-NEXT:  .LBB7_3: # %entry
1318; O1-NEXT:    jr $ra
1319; O1-NEXT:    daddiu $sp, $sp, 16
1320;
1321; O2-LABEL: AtomicCmpSwap64:
1322; O2:       # %bb.0: # %entry
1323; O2-NEXT:    daddiu $sp, $sp, -16
1324; O2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap64)))
1325; O2-NEXT:    daddu $1, $1, $25
1326; O2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap64)))
1327; O2-NEXT:    sd $5, 8($sp)
1328; O2-NEXT:    ld $1, %got_disp(x)($1)
1329; O2-NEXT:  .LBB7_1: # %entry
1330; O2-NEXT:    # =>This Inner Loop Header: Depth=1
1331; O2-NEXT:    lld $2, 0($1)
1332; O2-NEXT:    bne $2, $4, .LBB7_3
1333; O2-NEXT:    nop
1334; O2-NEXT:  # %bb.2: # %entry
1335; O2-NEXT:    # in Loop: Header=BB7_1 Depth=1
1336; O2-NEXT:    move $3, $5
1337; O2-NEXT:    scd $3, 0($1)
1338; O2-NEXT:    beqz $3, .LBB7_1
1339; O2-NEXT:    nop
1340; O2-NEXT:  .LBB7_3: # %entry
1341; O2-NEXT:    jr $ra
1342; O2-NEXT:    daddiu $sp, $sp, 16
1343;
1344; O3-LABEL: AtomicCmpSwap64:
1345; O3:       # %bb.0: # %entry
1346; O3-NEXT:    daddiu $sp, $sp, -16
1347; O3-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap64)))
1348; O3-NEXT:    sd $5, 8($sp)
1349; O3-NEXT:    daddu $1, $1, $25
1350; O3-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap64)))
1351; O3-NEXT:    ld $1, %got_disp(x)($1)
1352; O3-NEXT:  .LBB7_1: # %entry
1353; O3-NEXT:    # =>This Inner Loop Header: Depth=1
1354; O3-NEXT:    lld $2, 0($1)
1355; O3-NEXT:    bne $2, $4, .LBB7_3
1356; O3-NEXT:    nop
1357; O3-NEXT:  # %bb.2: # %entry
1358; O3-NEXT:    # in Loop: Header=BB7_1 Depth=1
1359; O3-NEXT:    move $3, $5
1360; O3-NEXT:    scd $3, 0($1)
1361; O3-NEXT:    beqz $3, .LBB7_1
1362; O3-NEXT:    nop
1363; O3-NEXT:  .LBB7_3: # %entry
1364; O3-NEXT:    jr $ra
1365; O3-NEXT:    daddiu $sp, $sp, 16
1366;
1367; MIPS64EB-LABEL: AtomicCmpSwap64:
1368; MIPS64EB:       # %bb.0: # %entry
1369; MIPS64EB-NEXT:    daddiu $sp, $sp, -16
1370; MIPS64EB-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap64)))
1371; MIPS64EB-NEXT:    daddu $1, $1, $25
1372; MIPS64EB-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap64)))
1373; MIPS64EB-NEXT:    sd $5, 8($sp)
1374; MIPS64EB-NEXT:    ld $1, %got_disp(x)($1)
1375; MIPS64EB-NEXT:  .LBB7_1: # %entry
1376; MIPS64EB-NEXT:    # =>This Inner Loop Header: Depth=1
1377; MIPS64EB-NEXT:    lld $2, 0($1)
1378; MIPS64EB-NEXT:    bne $2, $4, .LBB7_3
1379; MIPS64EB-NEXT:    nop
1380; MIPS64EB-NEXT:  # %bb.2: # %entry
1381; MIPS64EB-NEXT:    # in Loop: Header=BB7_1 Depth=1
1382; MIPS64EB-NEXT:    move $3, $5
1383; MIPS64EB-NEXT:    scd $3, 0($1)
1384; MIPS64EB-NEXT:    beqz $3, .LBB7_1
1385; MIPS64EB-NEXT:    nop
1386; MIPS64EB-NEXT:  .LBB7_3: # %entry
1387; MIPS64EB-NEXT:    jr $ra
1388; MIPS64EB-NEXT:    daddiu $sp, $sp, 16
1389entry:
1390  %newval.addr = alloca i64, align 4
1391  store i64 %newval, i64* %newval.addr, align 4
1392  %tmp = load i64, i64* %newval.addr, align 4
1393  %0 = cmpxchg i64* @x, i64 %oldval, i64 %tmp monotonic monotonic
1394  %1 = extractvalue { i64, i1 } %0, 0
1395  ret i64 %1
1396
1397}
1398