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