• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=mipsel-unknown-linux-gnu --disable-machine-licm -mcpu=mips32 -relocation-model=pic -verify-machineinstrs < %s | \
3; RUN:   FileCheck %s -check-prefix=MIPS32
4; RUN: llc -mtriple=mipsel-unknown-linux-gnu -O0 --disable-machine-licm -mcpu=mips32 -relocation-model=pic -verify-machineinstrs < %s | \
5; RUN:   FileCheck %s -check-prefix=MIPS32O0
6; RUN: llc -mtriple=mipsel-unknown-linux-gnu --disable-machine-licm -mcpu=mips32r2 -relocation-model=pic -verify-machineinstrs < %s | \
7; RUN:   FileCheck %s -check-prefix=MIPS32R2
8; RUN: llc -mtriple=mipsel-unknown-linux-gnu --disable-machine-licm -mcpu=mips32r6 -relocation-model=pic -verify-machineinstrs < %s | \
9; RUN:   FileCheck %s -check-prefix=MIPS32R6
10; RUN: llc -mtriple=mipsel-unknown-linux-gnu -O0 --disable-machine-licm -mcpu=mips32r6 -relocation-model=pic -verify-machineinstrs < %s | \
11; RUN:   FileCheck %s -check-prefix=MIPS32R6O0
12; RUN: llc -mtriple=mips64el-unknown-linux-gnu --disable-machine-licm -mcpu=mips4 -relocation-model=pic -verify-machineinstrs < %s | \
13; RUN:   FileCheck %s -check-prefix=MIPS4
14; RUN: llc -mtriple=mips64el-unknown-linux-gnu --disable-machine-licm -mcpu=mips64 -relocation-model=pic -verify-machineinstrs < %s | \
15; RUN:   FileCheck %s -check-prefix=MIPS64
16; RUN: llc -mtriple=mips64el-unknown-linux-gnu --disable-machine-licm -mcpu=mips64r2 -relocation-model=pic -verify-machineinstrs < %s | \
17; RUN:   FileCheck %s -check-prefix=MIPS64R2
18; RUN: llc -mtriple=mips64el-unknown-linux-gnu --disable-machine-licm -mcpu=mips64r6 -relocation-model=pic -verify-machineinstrs < %s | \
19; RUN:   FileCheck %s -check-prefix=MIPS64R6
20; RUN: llc -mtriple=mips64-unknown-linux-gnu -O0 -mcpu=mips64r6 -relocation-model=pic -verify-machineinstrs -verify-machineinstrs < %s | \
21; RUN:   FileCheck %s -check-prefix=MIPS64R6O0
22; RUN: llc -mtriple=mipsel-unknown-linux-gnu --disable-machine-licm -mcpu=mips32r2 -mattr=micromips -relocation-model=pic -verify-machineinstrs < %s | \
23; RUN:   FileCheck %s -check-prefix=MM32
24
25; We want to verify the produced code is well formed all optimization levels, the rest of the tests which ensure correctness.
26; RUN: llc -mtriple=mipsel-unknown-linux-gnu -O1 --disable-machine-licm -mcpu=mips32 -relocation-model=pic -verify-machineinstrs < %s | FileCheck %s --check-prefix=O1
27; RUN: llc -mtriple=mipsel-unknown-linux-gnu -O2 --disable-machine-licm -mcpu=mips32 -relocation-model=pic -verify-machineinstrs < %s | FileCheck %s --check-prefix=O2
28; RUN: llc -mtriple=mipsel-unknown-linux-gnu -O3 --disable-machine-licm -mcpu=mips32 -relocation-model=pic -verify-machineinstrs < %s | FileCheck %s --check-prefix=O3
29
30; Keep one big-endian check so that we don't reduce testing, but don't add more
31; since endianness doesn't affect the body of the atomic operations.
32; RUN: llc -mtriple=mips-unknown-linux-gnu   --disable-machine-licm -mcpu=mips32 -relocation-model=pic -verify-machineinstrs < %s | \
33; RUN:   FileCheck %s -check-prefix=MIPS32EB
34
35@x = common global i32 0, align 4
36
37define i32 @AtomicLoadAdd32(i32 signext %incr) nounwind {
38; MIPS32-LABEL: AtomicLoadAdd32:
39; MIPS32:       # %bb.0: # %entry
40; MIPS32-NEXT:    lui $2, %hi(_gp_disp)
41; MIPS32-NEXT:    addiu $2, $2, %lo(_gp_disp)
42; MIPS32-NEXT:    addu $1, $2, $25
43; MIPS32-NEXT:    lw $1, %got(x)($1)
44; MIPS32-NEXT:  $BB0_1: # %entry
45; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
46; MIPS32-NEXT:    ll $2, 0($1)
47; MIPS32-NEXT:    addu $3, $2, $4
48; MIPS32-NEXT:    sc $3, 0($1)
49; MIPS32-NEXT:    beqz $3, $BB0_1
50; MIPS32-NEXT:    nop
51; MIPS32-NEXT:  # %bb.2: # %entry
52; MIPS32-NEXT:    jr $ra
53; MIPS32-NEXT:    nop
54;
55; MIPS32O0-LABEL: AtomicLoadAdd32:
56; MIPS32O0:       # %bb.0: # %entry
57; MIPS32O0-NEXT:    lui $2, %hi(_gp_disp)
58; MIPS32O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
59; MIPS32O0-NEXT:    addu $1, $2, $25
60; MIPS32O0-NEXT:    lw $3, %got(x)($1)
61; MIPS32O0-NEXT:  $BB0_1: # %entry
62; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
63; MIPS32O0-NEXT:    ll $2, 0($3)
64; MIPS32O0-NEXT:    addu $1, $2, $4
65; MIPS32O0-NEXT:    sc $1, 0($3)
66; MIPS32O0-NEXT:    beqz $1, $BB0_1
67; MIPS32O0-NEXT:    nop
68; MIPS32O0-NEXT:  # %bb.2: # %entry
69; MIPS32O0-NEXT:    jr $ra
70; MIPS32O0-NEXT:    nop
71;
72; MIPS32R2-LABEL: AtomicLoadAdd32:
73; MIPS32R2:       # %bb.0: # %entry
74; MIPS32R2-NEXT:    lui $2, %hi(_gp_disp)
75; MIPS32R2-NEXT:    addiu $2, $2, %lo(_gp_disp)
76; MIPS32R2-NEXT:    addu $1, $2, $25
77; MIPS32R2-NEXT:    lw $1, %got(x)($1)
78; MIPS32R2-NEXT:  $BB0_1: # %entry
79; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
80; MIPS32R2-NEXT:    ll $2, 0($1)
81; MIPS32R2-NEXT:    addu $3, $2, $4
82; MIPS32R2-NEXT:    sc $3, 0($1)
83; MIPS32R2-NEXT:    beqz $3, $BB0_1
84; MIPS32R2-NEXT:    nop
85; MIPS32R2-NEXT:  # %bb.2: # %entry
86; MIPS32R2-NEXT:    jr $ra
87; MIPS32R2-NEXT:    nop
88;
89; MIPS32R6-LABEL: AtomicLoadAdd32:
90; MIPS32R6:       # %bb.0: # %entry
91; MIPS32R6-NEXT:    lui $2, %hi(_gp_disp)
92; MIPS32R6-NEXT:    addiu $2, $2, %lo(_gp_disp)
93; MIPS32R6-NEXT:    addu $1, $2, $25
94; MIPS32R6-NEXT:    lw $1, %got(x)($1)
95; MIPS32R6-NEXT:  $BB0_1: # %entry
96; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
97; MIPS32R6-NEXT:    ll $2, 0($1)
98; MIPS32R6-NEXT:    addu $3, $2, $4
99; MIPS32R6-NEXT:    sc $3, 0($1)
100; MIPS32R6-NEXT:    beqzc $3, $BB0_1
101; MIPS32R6-NEXT:    nop
102; MIPS32R6-NEXT:  # %bb.2: # %entry
103; MIPS32R6-NEXT:    jrc $ra
104;
105; MIPS32R6O0-LABEL: AtomicLoadAdd32:
106; MIPS32R6O0:       # %bb.0: # %entry
107; MIPS32R6O0-NEXT:    lui $2, %hi(_gp_disp)
108; MIPS32R6O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
109; MIPS32R6O0-NEXT:    addu $1, $2, $25
110; MIPS32R6O0-NEXT:    lw $3, %got(x)($1)
111; MIPS32R6O0-NEXT:  $BB0_1: # %entry
112; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
113; MIPS32R6O0-NEXT:    ll $2, 0($3)
114; MIPS32R6O0-NEXT:    addu $1, $2, $4
115; MIPS32R6O0-NEXT:    sc $1, 0($3)
116; MIPS32R6O0-NEXT:    beqzc $1, $BB0_1
117; MIPS32R6O0-NEXT:    nop
118; MIPS32R6O0-NEXT:  # %bb.2: # %entry
119; MIPS32R6O0-NEXT:    jrc $ra
120;
121; MIPS4-LABEL: AtomicLoadAdd32:
122; MIPS4:       # %bb.0: # %entry
123; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd32)))
124; MIPS4-NEXT:    daddu $1, $1, $25
125; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd32)))
126; MIPS4-NEXT:    ld $1, %got_disp(x)($1)
127; MIPS4-NEXT:  .LBB0_1: # %entry
128; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
129; MIPS4-NEXT:    ll $2, 0($1)
130; MIPS4-NEXT:    addu $3, $2, $4
131; MIPS4-NEXT:    sc $3, 0($1)
132; MIPS4-NEXT:    beqz $3, .LBB0_1
133; MIPS4-NEXT:    nop
134; MIPS4-NEXT:  # %bb.2: # %entry
135; MIPS4-NEXT:    jr $ra
136; MIPS4-NEXT:    nop
137;
138; MIPS64-LABEL: AtomicLoadAdd32:
139; MIPS64:       # %bb.0: # %entry
140; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd32)))
141; MIPS64-NEXT:    daddu $1, $1, $25
142; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd32)))
143; MIPS64-NEXT:    ld $1, %got_disp(x)($1)
144; MIPS64-NEXT:  .LBB0_1: # %entry
145; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
146; MIPS64-NEXT:    ll $2, 0($1)
147; MIPS64-NEXT:    addu $3, $2, $4
148; MIPS64-NEXT:    sc $3, 0($1)
149; MIPS64-NEXT:    beqz $3, .LBB0_1
150; MIPS64-NEXT:    nop
151; MIPS64-NEXT:  # %bb.2: # %entry
152; MIPS64-NEXT:    jr $ra
153; MIPS64-NEXT:    nop
154;
155; MIPS64R2-LABEL: AtomicLoadAdd32:
156; MIPS64R2:       # %bb.0: # %entry
157; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd32)))
158; MIPS64R2-NEXT:    daddu $1, $1, $25
159; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd32)))
160; MIPS64R2-NEXT:    ld $1, %got_disp(x)($1)
161; MIPS64R2-NEXT:  .LBB0_1: # %entry
162; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
163; MIPS64R2-NEXT:    ll $2, 0($1)
164; MIPS64R2-NEXT:    addu $3, $2, $4
165; MIPS64R2-NEXT:    sc $3, 0($1)
166; MIPS64R2-NEXT:    beqz $3, .LBB0_1
167; MIPS64R2-NEXT:    nop
168; MIPS64R2-NEXT:  # %bb.2: # %entry
169; MIPS64R2-NEXT:    jr $ra
170; MIPS64R2-NEXT:    nop
171;
172; MIPS64R6-LABEL: AtomicLoadAdd32:
173; MIPS64R6:       # %bb.0: # %entry
174; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd32)))
175; MIPS64R6-NEXT:    daddu $1, $1, $25
176; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd32)))
177; MIPS64R6-NEXT:    ld $1, %got_disp(x)($1)
178; MIPS64R6-NEXT:  .LBB0_1: # %entry
179; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
180; MIPS64R6-NEXT:    ll $2, 0($1)
181; MIPS64R6-NEXT:    addu $3, $2, $4
182; MIPS64R6-NEXT:    sc $3, 0($1)
183; MIPS64R6-NEXT:    beqzc $3, .LBB0_1
184; MIPS64R6-NEXT:    nop
185; MIPS64R6-NEXT:  # %bb.2: # %entry
186; MIPS64R6-NEXT:    jrc $ra
187;
188; MIPS64R6O0-LABEL: AtomicLoadAdd32:
189; MIPS64R6O0:       # %bb.0: # %entry
190; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd32)))
191; MIPS64R6O0-NEXT:    daddu $1, $1, $25
192; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd32)))
193; MIPS64R6O0-NEXT:    # kill: def $a0 killed $a0 killed $a0_64
194; MIPS64R6O0-NEXT:    ld $3, %got_disp(x)($1)
195; MIPS64R6O0-NEXT:  .LBB0_1: # %entry
196; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
197; MIPS64R6O0-NEXT:    ll $2, 0($3)
198; MIPS64R6O0-NEXT:    addu $1, $2, $4
199; MIPS64R6O0-NEXT:    sc $1, 0($3)
200; MIPS64R6O0-NEXT:    beqzc $1, .LBB0_1
201; MIPS64R6O0-NEXT:    nop
202; MIPS64R6O0-NEXT:  # %bb.2: # %entry
203; MIPS64R6O0-NEXT:    jrc $ra
204;
205; MM32-LABEL: AtomicLoadAdd32:
206; MM32:       # %bb.0: # %entry
207; MM32-NEXT:    lui $2, %hi(_gp_disp)
208; MM32-NEXT:    addiu $2, $2, %lo(_gp_disp)
209; MM32-NEXT:    addu $2, $2, $25
210; MM32-NEXT:    lw $1, %got(x)($2)
211; MM32-NEXT:  $BB0_1: # %entry
212; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
213; MM32-NEXT:    ll $2, 0($1)
214; MM32-NEXT:    addu16 $3, $2, $4
215; MM32-NEXT:    sc $3, 0($1)
216; MM32-NEXT:    beqzc $3, $BB0_1
217; MM32-NEXT:  # %bb.2: # %entry
218; MM32-NEXT:    jrc $ra
219;
220; O1-LABEL: AtomicLoadAdd32:
221; O1:       # %bb.0: # %entry
222; O1-NEXT:    lui $2, %hi(_gp_disp)
223; O1-NEXT:    addiu $2, $2, %lo(_gp_disp)
224; O1-NEXT:    addu $1, $2, $25
225; O1-NEXT:    lw $1, %got(x)($1)
226; O1-NEXT:  $BB0_1: # %entry
227; O1-NEXT:    # =>This Inner Loop Header: Depth=1
228; O1-NEXT:    ll $2, 0($1)
229; O1-NEXT:    addu $3, $2, $4
230; O1-NEXT:    sc $3, 0($1)
231; O1-NEXT:    beqz $3, $BB0_1
232; O1-NEXT:    nop
233; O1-NEXT:  # %bb.2: # %entry
234; O1-NEXT:    jr $ra
235; O1-NEXT:    nop
236;
237; O2-LABEL: AtomicLoadAdd32:
238; O2:       # %bb.0: # %entry
239; O2-NEXT:    lui $2, %hi(_gp_disp)
240; O2-NEXT:    addiu $2, $2, %lo(_gp_disp)
241; O2-NEXT:    addu $1, $2, $25
242; O2-NEXT:    lw $1, %got(x)($1)
243; O2-NEXT:  $BB0_1: # %entry
244; O2-NEXT:    # =>This Inner Loop Header: Depth=1
245; O2-NEXT:    ll $2, 0($1)
246; O2-NEXT:    addu $3, $2, $4
247; O2-NEXT:    sc $3, 0($1)
248; O2-NEXT:    beqz $3, $BB0_1
249; O2-NEXT:    nop
250; O2-NEXT:  # %bb.2: # %entry
251; O2-NEXT:    jr $ra
252; O2-NEXT:    nop
253;
254; O3-LABEL: AtomicLoadAdd32:
255; O3:       # %bb.0: # %entry
256; O3-NEXT:    lui $2, %hi(_gp_disp)
257; O3-NEXT:    addiu $2, $2, %lo(_gp_disp)
258; O3-NEXT:    addu $1, $2, $25
259; O3-NEXT:    lw $1, %got(x)($1)
260; O3-NEXT:  $BB0_1: # %entry
261; O3-NEXT:    # =>This Inner Loop Header: Depth=1
262; O3-NEXT:    ll $2, 0($1)
263; O3-NEXT:    addu $3, $2, $4
264; O3-NEXT:    sc $3, 0($1)
265; O3-NEXT:    beqz $3, $BB0_1
266; O3-NEXT:    nop
267; O3-NEXT:  # %bb.2: # %entry
268; O3-NEXT:    jr $ra
269; O3-NEXT:    nop
270;
271; MIPS32EB-LABEL: AtomicLoadAdd32:
272; MIPS32EB:       # %bb.0: # %entry
273; MIPS32EB-NEXT:    lui $2, %hi(_gp_disp)
274; MIPS32EB-NEXT:    addiu $2, $2, %lo(_gp_disp)
275; MIPS32EB-NEXT:    addu $1, $2, $25
276; MIPS32EB-NEXT:    lw $1, %got(x)($1)
277; MIPS32EB-NEXT:  $BB0_1: # %entry
278; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
279; MIPS32EB-NEXT:    ll $2, 0($1)
280; MIPS32EB-NEXT:    addu $3, $2, $4
281; MIPS32EB-NEXT:    sc $3, 0($1)
282; MIPS32EB-NEXT:    beqz $3, $BB0_1
283; MIPS32EB-NEXT:    nop
284; MIPS32EB-NEXT:  # %bb.2: # %entry
285; MIPS32EB-NEXT:    jr $ra
286; MIPS32EB-NEXT:    nop
287entry:
288  %0 = atomicrmw add i32* @x, i32 %incr monotonic
289  ret i32 %0
290
291}
292
293define i32 @AtomicLoadSub32(i32 signext %incr) nounwind {
294; MIPS32-LABEL: AtomicLoadSub32:
295; MIPS32:       # %bb.0: # %entry
296; MIPS32-NEXT:    lui $2, %hi(_gp_disp)
297; MIPS32-NEXT:    addiu $2, $2, %lo(_gp_disp)
298; MIPS32-NEXT:    addu $1, $2, $25
299; MIPS32-NEXT:    lw $1, %got(x)($1)
300; MIPS32-NEXT:  $BB1_1: # %entry
301; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
302; MIPS32-NEXT:    ll $2, 0($1)
303; MIPS32-NEXT:    subu $3, $2, $4
304; MIPS32-NEXT:    sc $3, 0($1)
305; MIPS32-NEXT:    beqz $3, $BB1_1
306; MIPS32-NEXT:    nop
307; MIPS32-NEXT:  # %bb.2: # %entry
308; MIPS32-NEXT:    jr $ra
309; MIPS32-NEXT:    nop
310;
311; MIPS32O0-LABEL: AtomicLoadSub32:
312; MIPS32O0:       # %bb.0: # %entry
313; MIPS32O0-NEXT:    lui $2, %hi(_gp_disp)
314; MIPS32O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
315; MIPS32O0-NEXT:    addu $1, $2, $25
316; MIPS32O0-NEXT:    lw $3, %got(x)($1)
317; MIPS32O0-NEXT:  $BB1_1: # %entry
318; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
319; MIPS32O0-NEXT:    ll $2, 0($3)
320; MIPS32O0-NEXT:    subu $1, $2, $4
321; MIPS32O0-NEXT:    sc $1, 0($3)
322; MIPS32O0-NEXT:    beqz $1, $BB1_1
323; MIPS32O0-NEXT:    nop
324; MIPS32O0-NEXT:  # %bb.2: # %entry
325; MIPS32O0-NEXT:    jr $ra
326; MIPS32O0-NEXT:    nop
327;
328; MIPS32R2-LABEL: AtomicLoadSub32:
329; MIPS32R2:       # %bb.0: # %entry
330; MIPS32R2-NEXT:    lui $2, %hi(_gp_disp)
331; MIPS32R2-NEXT:    addiu $2, $2, %lo(_gp_disp)
332; MIPS32R2-NEXT:    addu $1, $2, $25
333; MIPS32R2-NEXT:    lw $1, %got(x)($1)
334; MIPS32R2-NEXT:  $BB1_1: # %entry
335; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
336; MIPS32R2-NEXT:    ll $2, 0($1)
337; MIPS32R2-NEXT:    subu $3, $2, $4
338; MIPS32R2-NEXT:    sc $3, 0($1)
339; MIPS32R2-NEXT:    beqz $3, $BB1_1
340; MIPS32R2-NEXT:    nop
341; MIPS32R2-NEXT:  # %bb.2: # %entry
342; MIPS32R2-NEXT:    jr $ra
343; MIPS32R2-NEXT:    nop
344;
345; MIPS32R6-LABEL: AtomicLoadSub32:
346; MIPS32R6:       # %bb.0: # %entry
347; MIPS32R6-NEXT:    lui $2, %hi(_gp_disp)
348; MIPS32R6-NEXT:    addiu $2, $2, %lo(_gp_disp)
349; MIPS32R6-NEXT:    addu $1, $2, $25
350; MIPS32R6-NEXT:    lw $1, %got(x)($1)
351; MIPS32R6-NEXT:  $BB1_1: # %entry
352; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
353; MIPS32R6-NEXT:    ll $2, 0($1)
354; MIPS32R6-NEXT:    subu $3, $2, $4
355; MIPS32R6-NEXT:    sc $3, 0($1)
356; MIPS32R6-NEXT:    beqzc $3, $BB1_1
357; MIPS32R6-NEXT:    nop
358; MIPS32R6-NEXT:  # %bb.2: # %entry
359; MIPS32R6-NEXT:    jrc $ra
360;
361; MIPS32R6O0-LABEL: AtomicLoadSub32:
362; MIPS32R6O0:       # %bb.0: # %entry
363; MIPS32R6O0-NEXT:    lui $2, %hi(_gp_disp)
364; MIPS32R6O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
365; MIPS32R6O0-NEXT:    addu $1, $2, $25
366; MIPS32R6O0-NEXT:    lw $3, %got(x)($1)
367; MIPS32R6O0-NEXT:  $BB1_1: # %entry
368; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
369; MIPS32R6O0-NEXT:    ll $2, 0($3)
370; MIPS32R6O0-NEXT:    subu $1, $2, $4
371; MIPS32R6O0-NEXT:    sc $1, 0($3)
372; MIPS32R6O0-NEXT:    beqzc $1, $BB1_1
373; MIPS32R6O0-NEXT:    nop
374; MIPS32R6O0-NEXT:  # %bb.2: # %entry
375; MIPS32R6O0-NEXT:    jrc $ra
376;
377; MIPS4-LABEL: AtomicLoadSub32:
378; MIPS4:       # %bb.0: # %entry
379; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub32)))
380; MIPS4-NEXT:    daddu $1, $1, $25
381; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub32)))
382; MIPS4-NEXT:    ld $1, %got_disp(x)($1)
383; MIPS4-NEXT:  .LBB1_1: # %entry
384; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
385; MIPS4-NEXT:    ll $2, 0($1)
386; MIPS4-NEXT:    subu $3, $2, $4
387; MIPS4-NEXT:    sc $3, 0($1)
388; MIPS4-NEXT:    beqz $3, .LBB1_1
389; MIPS4-NEXT:    nop
390; MIPS4-NEXT:  # %bb.2: # %entry
391; MIPS4-NEXT:    jr $ra
392; MIPS4-NEXT:    nop
393;
394; MIPS64-LABEL: AtomicLoadSub32:
395; MIPS64:       # %bb.0: # %entry
396; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub32)))
397; MIPS64-NEXT:    daddu $1, $1, $25
398; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub32)))
399; MIPS64-NEXT:    ld $1, %got_disp(x)($1)
400; MIPS64-NEXT:  .LBB1_1: # %entry
401; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
402; MIPS64-NEXT:    ll $2, 0($1)
403; MIPS64-NEXT:    subu $3, $2, $4
404; MIPS64-NEXT:    sc $3, 0($1)
405; MIPS64-NEXT:    beqz $3, .LBB1_1
406; MIPS64-NEXT:    nop
407; MIPS64-NEXT:  # %bb.2: # %entry
408; MIPS64-NEXT:    jr $ra
409; MIPS64-NEXT:    nop
410;
411; MIPS64R2-LABEL: AtomicLoadSub32:
412; MIPS64R2:       # %bb.0: # %entry
413; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub32)))
414; MIPS64R2-NEXT:    daddu $1, $1, $25
415; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub32)))
416; MIPS64R2-NEXT:    ld $1, %got_disp(x)($1)
417; MIPS64R2-NEXT:  .LBB1_1: # %entry
418; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
419; MIPS64R2-NEXT:    ll $2, 0($1)
420; MIPS64R2-NEXT:    subu $3, $2, $4
421; MIPS64R2-NEXT:    sc $3, 0($1)
422; MIPS64R2-NEXT:    beqz $3, .LBB1_1
423; MIPS64R2-NEXT:    nop
424; MIPS64R2-NEXT:  # %bb.2: # %entry
425; MIPS64R2-NEXT:    jr $ra
426; MIPS64R2-NEXT:    nop
427;
428; MIPS64R6-LABEL: AtomicLoadSub32:
429; MIPS64R6:       # %bb.0: # %entry
430; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub32)))
431; MIPS64R6-NEXT:    daddu $1, $1, $25
432; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub32)))
433; MIPS64R6-NEXT:    ld $1, %got_disp(x)($1)
434; MIPS64R6-NEXT:  .LBB1_1: # %entry
435; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
436; MIPS64R6-NEXT:    ll $2, 0($1)
437; MIPS64R6-NEXT:    subu $3, $2, $4
438; MIPS64R6-NEXT:    sc $3, 0($1)
439; MIPS64R6-NEXT:    beqzc $3, .LBB1_1
440; MIPS64R6-NEXT:    nop
441; MIPS64R6-NEXT:  # %bb.2: # %entry
442; MIPS64R6-NEXT:    jrc $ra
443;
444; MIPS64R6O0-LABEL: AtomicLoadSub32:
445; MIPS64R6O0:       # %bb.0: # %entry
446; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub32)))
447; MIPS64R6O0-NEXT:    daddu $1, $1, $25
448; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub32)))
449; MIPS64R6O0-NEXT:    # kill: def $a0 killed $a0 killed $a0_64
450; MIPS64R6O0-NEXT:    ld $3, %got_disp(x)($1)
451; MIPS64R6O0-NEXT:  .LBB1_1: # %entry
452; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
453; MIPS64R6O0-NEXT:    ll $2, 0($3)
454; MIPS64R6O0-NEXT:    subu $1, $2, $4
455; MIPS64R6O0-NEXT:    sc $1, 0($3)
456; MIPS64R6O0-NEXT:    beqzc $1, .LBB1_1
457; MIPS64R6O0-NEXT:    nop
458; MIPS64R6O0-NEXT:  # %bb.2: # %entry
459; MIPS64R6O0-NEXT:    jrc $ra
460;
461; MM32-LABEL: AtomicLoadSub32:
462; MM32:       # %bb.0: # %entry
463; MM32-NEXT:    lui $2, %hi(_gp_disp)
464; MM32-NEXT:    addiu $2, $2, %lo(_gp_disp)
465; MM32-NEXT:    addu $2, $2, $25
466; MM32-NEXT:    lw $1, %got(x)($2)
467; MM32-NEXT:  $BB1_1: # %entry
468; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
469; MM32-NEXT:    ll $2, 0($1)
470; MM32-NEXT:    subu16 $3, $2, $4
471; MM32-NEXT:    sc $3, 0($1)
472; MM32-NEXT:    beqzc $3, $BB1_1
473; MM32-NEXT:  # %bb.2: # %entry
474; MM32-NEXT:    jrc $ra
475;
476; O1-LABEL: AtomicLoadSub32:
477; O1:       # %bb.0: # %entry
478; O1-NEXT:    lui $2, %hi(_gp_disp)
479; O1-NEXT:    addiu $2, $2, %lo(_gp_disp)
480; O1-NEXT:    addu $1, $2, $25
481; O1-NEXT:    lw $1, %got(x)($1)
482; O1-NEXT:  $BB1_1: # %entry
483; O1-NEXT:    # =>This Inner Loop Header: Depth=1
484; O1-NEXT:    ll $2, 0($1)
485; O1-NEXT:    subu $3, $2, $4
486; O1-NEXT:    sc $3, 0($1)
487; O1-NEXT:    beqz $3, $BB1_1
488; O1-NEXT:    nop
489; O1-NEXT:  # %bb.2: # %entry
490; O1-NEXT:    jr $ra
491; O1-NEXT:    nop
492;
493; O2-LABEL: AtomicLoadSub32:
494; O2:       # %bb.0: # %entry
495; O2-NEXT:    lui $2, %hi(_gp_disp)
496; O2-NEXT:    addiu $2, $2, %lo(_gp_disp)
497; O2-NEXT:    addu $1, $2, $25
498; O2-NEXT:    lw $1, %got(x)($1)
499; O2-NEXT:  $BB1_1: # %entry
500; O2-NEXT:    # =>This Inner Loop Header: Depth=1
501; O2-NEXT:    ll $2, 0($1)
502; O2-NEXT:    subu $3, $2, $4
503; O2-NEXT:    sc $3, 0($1)
504; O2-NEXT:    beqz $3, $BB1_1
505; O2-NEXT:    nop
506; O2-NEXT:  # %bb.2: # %entry
507; O2-NEXT:    jr $ra
508; O2-NEXT:    nop
509;
510; O3-LABEL: AtomicLoadSub32:
511; O3:       # %bb.0: # %entry
512; O3-NEXT:    lui $2, %hi(_gp_disp)
513; O3-NEXT:    addiu $2, $2, %lo(_gp_disp)
514; O3-NEXT:    addu $1, $2, $25
515; O3-NEXT:    lw $1, %got(x)($1)
516; O3-NEXT:  $BB1_1: # %entry
517; O3-NEXT:    # =>This Inner Loop Header: Depth=1
518; O3-NEXT:    ll $2, 0($1)
519; O3-NEXT:    subu $3, $2, $4
520; O3-NEXT:    sc $3, 0($1)
521; O3-NEXT:    beqz $3, $BB1_1
522; O3-NEXT:    nop
523; O3-NEXT:  # %bb.2: # %entry
524; O3-NEXT:    jr $ra
525; O3-NEXT:    nop
526;
527; MIPS32EB-LABEL: AtomicLoadSub32:
528; MIPS32EB:       # %bb.0: # %entry
529; MIPS32EB-NEXT:    lui $2, %hi(_gp_disp)
530; MIPS32EB-NEXT:    addiu $2, $2, %lo(_gp_disp)
531; MIPS32EB-NEXT:    addu $1, $2, $25
532; MIPS32EB-NEXT:    lw $1, %got(x)($1)
533; MIPS32EB-NEXT:  $BB1_1: # %entry
534; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
535; MIPS32EB-NEXT:    ll $2, 0($1)
536; MIPS32EB-NEXT:    subu $3, $2, $4
537; MIPS32EB-NEXT:    sc $3, 0($1)
538; MIPS32EB-NEXT:    beqz $3, $BB1_1
539; MIPS32EB-NEXT:    nop
540; MIPS32EB-NEXT:  # %bb.2: # %entry
541; MIPS32EB-NEXT:    jr $ra
542; MIPS32EB-NEXT:    nop
543entry:
544  %0 = atomicrmw sub i32* @x, i32 %incr monotonic
545  ret i32 %0
546
547}
548
549define i32 @AtomicLoadXor32(i32 signext %incr) nounwind {
550; MIPS32-LABEL: AtomicLoadXor32:
551; MIPS32:       # %bb.0: # %entry
552; MIPS32-NEXT:    lui $2, %hi(_gp_disp)
553; MIPS32-NEXT:    addiu $2, $2, %lo(_gp_disp)
554; MIPS32-NEXT:    addu $1, $2, $25
555; MIPS32-NEXT:    lw $1, %got(x)($1)
556; MIPS32-NEXT:  $BB2_1: # %entry
557; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
558; MIPS32-NEXT:    ll $2, 0($1)
559; MIPS32-NEXT:    xor $3, $2, $4
560; MIPS32-NEXT:    sc $3, 0($1)
561; MIPS32-NEXT:    beqz $3, $BB2_1
562; MIPS32-NEXT:    nop
563; MIPS32-NEXT:  # %bb.2: # %entry
564; MIPS32-NEXT:    jr $ra
565; MIPS32-NEXT:    nop
566;
567; MIPS32O0-LABEL: AtomicLoadXor32:
568; MIPS32O0:       # %bb.0: # %entry
569; MIPS32O0-NEXT:    lui $2, %hi(_gp_disp)
570; MIPS32O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
571; MIPS32O0-NEXT:    addu $1, $2, $25
572; MIPS32O0-NEXT:    lw $3, %got(x)($1)
573; MIPS32O0-NEXT:  $BB2_1: # %entry
574; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
575; MIPS32O0-NEXT:    ll $2, 0($3)
576; MIPS32O0-NEXT:    xor $1, $2, $4
577; MIPS32O0-NEXT:    sc $1, 0($3)
578; MIPS32O0-NEXT:    beqz $1, $BB2_1
579; MIPS32O0-NEXT:    nop
580; MIPS32O0-NEXT:  # %bb.2: # %entry
581; MIPS32O0-NEXT:    jr $ra
582; MIPS32O0-NEXT:    nop
583;
584; MIPS32R2-LABEL: AtomicLoadXor32:
585; MIPS32R2:       # %bb.0: # %entry
586; MIPS32R2-NEXT:    lui $2, %hi(_gp_disp)
587; MIPS32R2-NEXT:    addiu $2, $2, %lo(_gp_disp)
588; MIPS32R2-NEXT:    addu $1, $2, $25
589; MIPS32R2-NEXT:    lw $1, %got(x)($1)
590; MIPS32R2-NEXT:  $BB2_1: # %entry
591; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
592; MIPS32R2-NEXT:    ll $2, 0($1)
593; MIPS32R2-NEXT:    xor $3, $2, $4
594; MIPS32R2-NEXT:    sc $3, 0($1)
595; MIPS32R2-NEXT:    beqz $3, $BB2_1
596; MIPS32R2-NEXT:    nop
597; MIPS32R2-NEXT:  # %bb.2: # %entry
598; MIPS32R2-NEXT:    jr $ra
599; MIPS32R2-NEXT:    nop
600;
601; MIPS32R6-LABEL: AtomicLoadXor32:
602; MIPS32R6:       # %bb.0: # %entry
603; MIPS32R6-NEXT:    lui $2, %hi(_gp_disp)
604; MIPS32R6-NEXT:    addiu $2, $2, %lo(_gp_disp)
605; MIPS32R6-NEXT:    addu $1, $2, $25
606; MIPS32R6-NEXT:    lw $1, %got(x)($1)
607; MIPS32R6-NEXT:  $BB2_1: # %entry
608; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
609; MIPS32R6-NEXT:    ll $2, 0($1)
610; MIPS32R6-NEXT:    xor $3, $2, $4
611; MIPS32R6-NEXT:    sc $3, 0($1)
612; MIPS32R6-NEXT:    beqzc $3, $BB2_1
613; MIPS32R6-NEXT:    nop
614; MIPS32R6-NEXT:  # %bb.2: # %entry
615; MIPS32R6-NEXT:    jrc $ra
616;
617; MIPS32R6O0-LABEL: AtomicLoadXor32:
618; MIPS32R6O0:       # %bb.0: # %entry
619; MIPS32R6O0-NEXT:    lui $2, %hi(_gp_disp)
620; MIPS32R6O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
621; MIPS32R6O0-NEXT:    addu $1, $2, $25
622; MIPS32R6O0-NEXT:    lw $3, %got(x)($1)
623; MIPS32R6O0-NEXT:  $BB2_1: # %entry
624; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
625; MIPS32R6O0-NEXT:    ll $2, 0($3)
626; MIPS32R6O0-NEXT:    xor $1, $2, $4
627; MIPS32R6O0-NEXT:    sc $1, 0($3)
628; MIPS32R6O0-NEXT:    beqzc $1, $BB2_1
629; MIPS32R6O0-NEXT:    nop
630; MIPS32R6O0-NEXT:  # %bb.2: # %entry
631; MIPS32R6O0-NEXT:    jrc $ra
632;
633; MIPS4-LABEL: AtomicLoadXor32:
634; MIPS4:       # %bb.0: # %entry
635; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadXor32)))
636; MIPS4-NEXT:    daddu $1, $1, $25
637; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadXor32)))
638; MIPS4-NEXT:    ld $1, %got_disp(x)($1)
639; MIPS4-NEXT:  .LBB2_1: # %entry
640; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
641; MIPS4-NEXT:    ll $2, 0($1)
642; MIPS4-NEXT:    xor $3, $2, $4
643; MIPS4-NEXT:    sc $3, 0($1)
644; MIPS4-NEXT:    beqz $3, .LBB2_1
645; MIPS4-NEXT:    nop
646; MIPS4-NEXT:  # %bb.2: # %entry
647; MIPS4-NEXT:    jr $ra
648; MIPS4-NEXT:    nop
649;
650; MIPS64-LABEL: AtomicLoadXor32:
651; MIPS64:       # %bb.0: # %entry
652; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadXor32)))
653; MIPS64-NEXT:    daddu $1, $1, $25
654; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadXor32)))
655; MIPS64-NEXT:    ld $1, %got_disp(x)($1)
656; MIPS64-NEXT:  .LBB2_1: # %entry
657; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
658; MIPS64-NEXT:    ll $2, 0($1)
659; MIPS64-NEXT:    xor $3, $2, $4
660; MIPS64-NEXT:    sc $3, 0($1)
661; MIPS64-NEXT:    beqz $3, .LBB2_1
662; MIPS64-NEXT:    nop
663; MIPS64-NEXT:  # %bb.2: # %entry
664; MIPS64-NEXT:    jr $ra
665; MIPS64-NEXT:    nop
666;
667; MIPS64R2-LABEL: AtomicLoadXor32:
668; MIPS64R2:       # %bb.0: # %entry
669; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadXor32)))
670; MIPS64R2-NEXT:    daddu $1, $1, $25
671; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadXor32)))
672; MIPS64R2-NEXT:    ld $1, %got_disp(x)($1)
673; MIPS64R2-NEXT:  .LBB2_1: # %entry
674; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
675; MIPS64R2-NEXT:    ll $2, 0($1)
676; MIPS64R2-NEXT:    xor $3, $2, $4
677; MIPS64R2-NEXT:    sc $3, 0($1)
678; MIPS64R2-NEXT:    beqz $3, .LBB2_1
679; MIPS64R2-NEXT:    nop
680; MIPS64R2-NEXT:  # %bb.2: # %entry
681; MIPS64R2-NEXT:    jr $ra
682; MIPS64R2-NEXT:    nop
683;
684; MIPS64R6-LABEL: AtomicLoadXor32:
685; MIPS64R6:       # %bb.0: # %entry
686; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadXor32)))
687; MIPS64R6-NEXT:    daddu $1, $1, $25
688; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadXor32)))
689; MIPS64R6-NEXT:    ld $1, %got_disp(x)($1)
690; MIPS64R6-NEXT:  .LBB2_1: # %entry
691; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
692; MIPS64R6-NEXT:    ll $2, 0($1)
693; MIPS64R6-NEXT:    xor $3, $2, $4
694; MIPS64R6-NEXT:    sc $3, 0($1)
695; MIPS64R6-NEXT:    beqzc $3, .LBB2_1
696; MIPS64R6-NEXT:    nop
697; MIPS64R6-NEXT:  # %bb.2: # %entry
698; MIPS64R6-NEXT:    jrc $ra
699;
700; MIPS64R6O0-LABEL: AtomicLoadXor32:
701; MIPS64R6O0:       # %bb.0: # %entry
702; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadXor32)))
703; MIPS64R6O0-NEXT:    daddu $1, $1, $25
704; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadXor32)))
705; MIPS64R6O0-NEXT:    # kill: def $a0 killed $a0 killed $a0_64
706; MIPS64R6O0-NEXT:    ld $3, %got_disp(x)($1)
707; MIPS64R6O0-NEXT:  .LBB2_1: # %entry
708; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
709; MIPS64R6O0-NEXT:    ll $2, 0($3)
710; MIPS64R6O0-NEXT:    xor $1, $2, $4
711; MIPS64R6O0-NEXT:    sc $1, 0($3)
712; MIPS64R6O0-NEXT:    beqzc $1, .LBB2_1
713; MIPS64R6O0-NEXT:    nop
714; MIPS64R6O0-NEXT:  # %bb.2: # %entry
715; MIPS64R6O0-NEXT:    jrc $ra
716;
717; MM32-LABEL: AtomicLoadXor32:
718; MM32:       # %bb.0: # %entry
719; MM32-NEXT:    lui $2, %hi(_gp_disp)
720; MM32-NEXT:    addiu $2, $2, %lo(_gp_disp)
721; MM32-NEXT:    addu $2, $2, $25
722; MM32-NEXT:    lw $1, %got(x)($2)
723; MM32-NEXT:  $BB2_1: # %entry
724; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
725; MM32-NEXT:    ll $2, 0($1)
726; MM32-NEXT:    xor $3, $2, $4
727; MM32-NEXT:    sc $3, 0($1)
728; MM32-NEXT:    beqzc $3, $BB2_1
729; MM32-NEXT:  # %bb.2: # %entry
730; MM32-NEXT:    jrc $ra
731;
732; O1-LABEL: AtomicLoadXor32:
733; O1:       # %bb.0: # %entry
734; O1-NEXT:    lui $2, %hi(_gp_disp)
735; O1-NEXT:    addiu $2, $2, %lo(_gp_disp)
736; O1-NEXT:    addu $1, $2, $25
737; O1-NEXT:    lw $1, %got(x)($1)
738; O1-NEXT:  $BB2_1: # %entry
739; O1-NEXT:    # =>This Inner Loop Header: Depth=1
740; O1-NEXT:    ll $2, 0($1)
741; O1-NEXT:    xor $3, $2, $4
742; O1-NEXT:    sc $3, 0($1)
743; O1-NEXT:    beqz $3, $BB2_1
744; O1-NEXT:    nop
745; O1-NEXT:  # %bb.2: # %entry
746; O1-NEXT:    jr $ra
747; O1-NEXT:    nop
748;
749; O2-LABEL: AtomicLoadXor32:
750; O2:       # %bb.0: # %entry
751; O2-NEXT:    lui $2, %hi(_gp_disp)
752; O2-NEXT:    addiu $2, $2, %lo(_gp_disp)
753; O2-NEXT:    addu $1, $2, $25
754; O2-NEXT:    lw $1, %got(x)($1)
755; O2-NEXT:  $BB2_1: # %entry
756; O2-NEXT:    # =>This Inner Loop Header: Depth=1
757; O2-NEXT:    ll $2, 0($1)
758; O2-NEXT:    xor $3, $2, $4
759; O2-NEXT:    sc $3, 0($1)
760; O2-NEXT:    beqz $3, $BB2_1
761; O2-NEXT:    nop
762; O2-NEXT:  # %bb.2: # %entry
763; O2-NEXT:    jr $ra
764; O2-NEXT:    nop
765;
766; O3-LABEL: AtomicLoadXor32:
767; O3:       # %bb.0: # %entry
768; O3-NEXT:    lui $2, %hi(_gp_disp)
769; O3-NEXT:    addiu $2, $2, %lo(_gp_disp)
770; O3-NEXT:    addu $1, $2, $25
771; O3-NEXT:    lw $1, %got(x)($1)
772; O3-NEXT:  $BB2_1: # %entry
773; O3-NEXT:    # =>This Inner Loop Header: Depth=1
774; O3-NEXT:    ll $2, 0($1)
775; O3-NEXT:    xor $3, $2, $4
776; O3-NEXT:    sc $3, 0($1)
777; O3-NEXT:    beqz $3, $BB2_1
778; O3-NEXT:    nop
779; O3-NEXT:  # %bb.2: # %entry
780; O3-NEXT:    jr $ra
781; O3-NEXT:    nop
782;
783; MIPS32EB-LABEL: AtomicLoadXor32:
784; MIPS32EB:       # %bb.0: # %entry
785; MIPS32EB-NEXT:    lui $2, %hi(_gp_disp)
786; MIPS32EB-NEXT:    addiu $2, $2, %lo(_gp_disp)
787; MIPS32EB-NEXT:    addu $1, $2, $25
788; MIPS32EB-NEXT:    lw $1, %got(x)($1)
789; MIPS32EB-NEXT:  $BB2_1: # %entry
790; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
791; MIPS32EB-NEXT:    ll $2, 0($1)
792; MIPS32EB-NEXT:    xor $3, $2, $4
793; MIPS32EB-NEXT:    sc $3, 0($1)
794; MIPS32EB-NEXT:    beqz $3, $BB2_1
795; MIPS32EB-NEXT:    nop
796; MIPS32EB-NEXT:  # %bb.2: # %entry
797; MIPS32EB-NEXT:    jr $ra
798; MIPS32EB-NEXT:    nop
799entry:
800  %0 = atomicrmw xor i32* @x, i32 %incr monotonic
801  ret i32 %0
802}
803
804define i32 @AtomicLoadOr32(i32 signext %incr) nounwind {
805; MIPS32-LABEL: AtomicLoadOr32:
806; MIPS32:       # %bb.0: # %entry
807; MIPS32-NEXT:    lui $2, %hi(_gp_disp)
808; MIPS32-NEXT:    addiu $2, $2, %lo(_gp_disp)
809; MIPS32-NEXT:    addu $1, $2, $25
810; MIPS32-NEXT:    lw $1, %got(x)($1)
811; MIPS32-NEXT:  $BB3_1: # %entry
812; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
813; MIPS32-NEXT:    ll $2, 0($1)
814; MIPS32-NEXT:    or $3, $2, $4
815; MIPS32-NEXT:    sc $3, 0($1)
816; MIPS32-NEXT:    beqz $3, $BB3_1
817; MIPS32-NEXT:    nop
818; MIPS32-NEXT:  # %bb.2: # %entry
819; MIPS32-NEXT:    jr $ra
820; MIPS32-NEXT:    nop
821;
822; MIPS32O0-LABEL: AtomicLoadOr32:
823; MIPS32O0:       # %bb.0: # %entry
824; MIPS32O0-NEXT:    lui $2, %hi(_gp_disp)
825; MIPS32O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
826; MIPS32O0-NEXT:    addu $1, $2, $25
827; MIPS32O0-NEXT:    lw $3, %got(x)($1)
828; MIPS32O0-NEXT:  $BB3_1: # %entry
829; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
830; MIPS32O0-NEXT:    ll $2, 0($3)
831; MIPS32O0-NEXT:    or $1, $2, $4
832; MIPS32O0-NEXT:    sc $1, 0($3)
833; MIPS32O0-NEXT:    beqz $1, $BB3_1
834; MIPS32O0-NEXT:    nop
835; MIPS32O0-NEXT:  # %bb.2: # %entry
836; MIPS32O0-NEXT:    jr $ra
837; MIPS32O0-NEXT:    nop
838;
839; MIPS32R2-LABEL: AtomicLoadOr32:
840; MIPS32R2:       # %bb.0: # %entry
841; MIPS32R2-NEXT:    lui $2, %hi(_gp_disp)
842; MIPS32R2-NEXT:    addiu $2, $2, %lo(_gp_disp)
843; MIPS32R2-NEXT:    addu $1, $2, $25
844; MIPS32R2-NEXT:    lw $1, %got(x)($1)
845; MIPS32R2-NEXT:  $BB3_1: # %entry
846; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
847; MIPS32R2-NEXT:    ll $2, 0($1)
848; MIPS32R2-NEXT:    or $3, $2, $4
849; MIPS32R2-NEXT:    sc $3, 0($1)
850; MIPS32R2-NEXT:    beqz $3, $BB3_1
851; MIPS32R2-NEXT:    nop
852; MIPS32R2-NEXT:  # %bb.2: # %entry
853; MIPS32R2-NEXT:    jr $ra
854; MIPS32R2-NEXT:    nop
855;
856; MIPS32R6-LABEL: AtomicLoadOr32:
857; MIPS32R6:       # %bb.0: # %entry
858; MIPS32R6-NEXT:    lui $2, %hi(_gp_disp)
859; MIPS32R6-NEXT:    addiu $2, $2, %lo(_gp_disp)
860; MIPS32R6-NEXT:    addu $1, $2, $25
861; MIPS32R6-NEXT:    lw $1, %got(x)($1)
862; MIPS32R6-NEXT:  $BB3_1: # %entry
863; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
864; MIPS32R6-NEXT:    ll $2, 0($1)
865; MIPS32R6-NEXT:    or $3, $2, $4
866; MIPS32R6-NEXT:    sc $3, 0($1)
867; MIPS32R6-NEXT:    beqzc $3, $BB3_1
868; MIPS32R6-NEXT:    nop
869; MIPS32R6-NEXT:  # %bb.2: # %entry
870; MIPS32R6-NEXT:    jrc $ra
871;
872; MIPS32R6O0-LABEL: AtomicLoadOr32:
873; MIPS32R6O0:       # %bb.0: # %entry
874; MIPS32R6O0-NEXT:    lui $2, %hi(_gp_disp)
875; MIPS32R6O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
876; MIPS32R6O0-NEXT:    addu $1, $2, $25
877; MIPS32R6O0-NEXT:    lw $3, %got(x)($1)
878; MIPS32R6O0-NEXT:  $BB3_1: # %entry
879; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
880; MIPS32R6O0-NEXT:    ll $2, 0($3)
881; MIPS32R6O0-NEXT:    or $1, $2, $4
882; MIPS32R6O0-NEXT:    sc $1, 0($3)
883; MIPS32R6O0-NEXT:    beqzc $1, $BB3_1
884; MIPS32R6O0-NEXT:    nop
885; MIPS32R6O0-NEXT:  # %bb.2: # %entry
886; MIPS32R6O0-NEXT:    jrc $ra
887;
888; MIPS4-LABEL: AtomicLoadOr32:
889; MIPS4:       # %bb.0: # %entry
890; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadOr32)))
891; MIPS4-NEXT:    daddu $1, $1, $25
892; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadOr32)))
893; MIPS4-NEXT:    ld $1, %got_disp(x)($1)
894; MIPS4-NEXT:  .LBB3_1: # %entry
895; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
896; MIPS4-NEXT:    ll $2, 0($1)
897; MIPS4-NEXT:    or $3, $2, $4
898; MIPS4-NEXT:    sc $3, 0($1)
899; MIPS4-NEXT:    beqz $3, .LBB3_1
900; MIPS4-NEXT:    nop
901; MIPS4-NEXT:  # %bb.2: # %entry
902; MIPS4-NEXT:    jr $ra
903; MIPS4-NEXT:    nop
904;
905; MIPS64-LABEL: AtomicLoadOr32:
906; MIPS64:       # %bb.0: # %entry
907; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadOr32)))
908; MIPS64-NEXT:    daddu $1, $1, $25
909; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadOr32)))
910; MIPS64-NEXT:    ld $1, %got_disp(x)($1)
911; MIPS64-NEXT:  .LBB3_1: # %entry
912; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
913; MIPS64-NEXT:    ll $2, 0($1)
914; MIPS64-NEXT:    or $3, $2, $4
915; MIPS64-NEXT:    sc $3, 0($1)
916; MIPS64-NEXT:    beqz $3, .LBB3_1
917; MIPS64-NEXT:    nop
918; MIPS64-NEXT:  # %bb.2: # %entry
919; MIPS64-NEXT:    jr $ra
920; MIPS64-NEXT:    nop
921;
922; MIPS64R2-LABEL: AtomicLoadOr32:
923; MIPS64R2:       # %bb.0: # %entry
924; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadOr32)))
925; MIPS64R2-NEXT:    daddu $1, $1, $25
926; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadOr32)))
927; MIPS64R2-NEXT:    ld $1, %got_disp(x)($1)
928; MIPS64R2-NEXT:  .LBB3_1: # %entry
929; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
930; MIPS64R2-NEXT:    ll $2, 0($1)
931; MIPS64R2-NEXT:    or $3, $2, $4
932; MIPS64R2-NEXT:    sc $3, 0($1)
933; MIPS64R2-NEXT:    beqz $3, .LBB3_1
934; MIPS64R2-NEXT:    nop
935; MIPS64R2-NEXT:  # %bb.2: # %entry
936; MIPS64R2-NEXT:    jr $ra
937; MIPS64R2-NEXT:    nop
938;
939; MIPS64R6-LABEL: AtomicLoadOr32:
940; MIPS64R6:       # %bb.0: # %entry
941; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadOr32)))
942; MIPS64R6-NEXT:    daddu $1, $1, $25
943; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadOr32)))
944; MIPS64R6-NEXT:    ld $1, %got_disp(x)($1)
945; MIPS64R6-NEXT:  .LBB3_1: # %entry
946; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
947; MIPS64R6-NEXT:    ll $2, 0($1)
948; MIPS64R6-NEXT:    or $3, $2, $4
949; MIPS64R6-NEXT:    sc $3, 0($1)
950; MIPS64R6-NEXT:    beqzc $3, .LBB3_1
951; MIPS64R6-NEXT:    nop
952; MIPS64R6-NEXT:  # %bb.2: # %entry
953; MIPS64R6-NEXT:    jrc $ra
954;
955; MIPS64R6O0-LABEL: AtomicLoadOr32:
956; MIPS64R6O0:       # %bb.0: # %entry
957; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadOr32)))
958; MIPS64R6O0-NEXT:    daddu $1, $1, $25
959; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadOr32)))
960; MIPS64R6O0-NEXT:    # kill: def $a0 killed $a0 killed $a0_64
961; MIPS64R6O0-NEXT:    ld $3, %got_disp(x)($1)
962; MIPS64R6O0-NEXT:  .LBB3_1: # %entry
963; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
964; MIPS64R6O0-NEXT:    ll $2, 0($3)
965; MIPS64R6O0-NEXT:    or $1, $2, $4
966; MIPS64R6O0-NEXT:    sc $1, 0($3)
967; MIPS64R6O0-NEXT:    beqzc $1, .LBB3_1
968; MIPS64R6O0-NEXT:    nop
969; MIPS64R6O0-NEXT:  # %bb.2: # %entry
970; MIPS64R6O0-NEXT:    jrc $ra
971;
972; MM32-LABEL: AtomicLoadOr32:
973; MM32:       # %bb.0: # %entry
974; MM32-NEXT:    lui $2, %hi(_gp_disp)
975; MM32-NEXT:    addiu $2, $2, %lo(_gp_disp)
976; MM32-NEXT:    addu $2, $2, $25
977; MM32-NEXT:    lw $1, %got(x)($2)
978; MM32-NEXT:  $BB3_1: # %entry
979; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
980; MM32-NEXT:    ll $2, 0($1)
981; MM32-NEXT:    or $3, $2, $4
982; MM32-NEXT:    sc $3, 0($1)
983; MM32-NEXT:    beqzc $3, $BB3_1
984; MM32-NEXT:  # %bb.2: # %entry
985; MM32-NEXT:    jrc $ra
986;
987; O1-LABEL: AtomicLoadOr32:
988; O1:       # %bb.0: # %entry
989; O1-NEXT:    lui $2, %hi(_gp_disp)
990; O1-NEXT:    addiu $2, $2, %lo(_gp_disp)
991; O1-NEXT:    addu $1, $2, $25
992; O1-NEXT:    lw $1, %got(x)($1)
993; O1-NEXT:  $BB3_1: # %entry
994; O1-NEXT:    # =>This Inner Loop Header: Depth=1
995; O1-NEXT:    ll $2, 0($1)
996; O1-NEXT:    or $3, $2, $4
997; O1-NEXT:    sc $3, 0($1)
998; O1-NEXT:    beqz $3, $BB3_1
999; O1-NEXT:    nop
1000; O1-NEXT:  # %bb.2: # %entry
1001; O1-NEXT:    jr $ra
1002; O1-NEXT:    nop
1003;
1004; O2-LABEL: AtomicLoadOr32:
1005; O2:       # %bb.0: # %entry
1006; O2-NEXT:    lui $2, %hi(_gp_disp)
1007; O2-NEXT:    addiu $2, $2, %lo(_gp_disp)
1008; O2-NEXT:    addu $1, $2, $25
1009; O2-NEXT:    lw $1, %got(x)($1)
1010; O2-NEXT:  $BB3_1: # %entry
1011; O2-NEXT:    # =>This Inner Loop Header: Depth=1
1012; O2-NEXT:    ll $2, 0($1)
1013; O2-NEXT:    or $3, $2, $4
1014; O2-NEXT:    sc $3, 0($1)
1015; O2-NEXT:    beqz $3, $BB3_1
1016; O2-NEXT:    nop
1017; O2-NEXT:  # %bb.2: # %entry
1018; O2-NEXT:    jr $ra
1019; O2-NEXT:    nop
1020;
1021; O3-LABEL: AtomicLoadOr32:
1022; O3:       # %bb.0: # %entry
1023; O3-NEXT:    lui $2, %hi(_gp_disp)
1024; O3-NEXT:    addiu $2, $2, %lo(_gp_disp)
1025; O3-NEXT:    addu $1, $2, $25
1026; O3-NEXT:    lw $1, %got(x)($1)
1027; O3-NEXT:  $BB3_1: # %entry
1028; O3-NEXT:    # =>This Inner Loop Header: Depth=1
1029; O3-NEXT:    ll $2, 0($1)
1030; O3-NEXT:    or $3, $2, $4
1031; O3-NEXT:    sc $3, 0($1)
1032; O3-NEXT:    beqz $3, $BB3_1
1033; O3-NEXT:    nop
1034; O3-NEXT:  # %bb.2: # %entry
1035; O3-NEXT:    jr $ra
1036; O3-NEXT:    nop
1037;
1038; MIPS32EB-LABEL: AtomicLoadOr32:
1039; MIPS32EB:       # %bb.0: # %entry
1040; MIPS32EB-NEXT:    lui $2, %hi(_gp_disp)
1041; MIPS32EB-NEXT:    addiu $2, $2, %lo(_gp_disp)
1042; MIPS32EB-NEXT:    addu $1, $2, $25
1043; MIPS32EB-NEXT:    lw $1, %got(x)($1)
1044; MIPS32EB-NEXT:  $BB3_1: # %entry
1045; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
1046; MIPS32EB-NEXT:    ll $2, 0($1)
1047; MIPS32EB-NEXT:    or $3, $2, $4
1048; MIPS32EB-NEXT:    sc $3, 0($1)
1049; MIPS32EB-NEXT:    beqz $3, $BB3_1
1050; MIPS32EB-NEXT:    nop
1051; MIPS32EB-NEXT:  # %bb.2: # %entry
1052; MIPS32EB-NEXT:    jr $ra
1053; MIPS32EB-NEXT:    nop
1054entry:
1055  %0 = atomicrmw or i32* @x, i32 %incr monotonic
1056  ret i32 %0
1057}
1058
1059define i32 @AtomicLoadAnd32(i32 signext %incr) nounwind {
1060; MIPS32-LABEL: AtomicLoadAnd32:
1061; MIPS32:       # %bb.0: # %entry
1062; MIPS32-NEXT:    lui $2, %hi(_gp_disp)
1063; MIPS32-NEXT:    addiu $2, $2, %lo(_gp_disp)
1064; MIPS32-NEXT:    addu $1, $2, $25
1065; MIPS32-NEXT:    lw $1, %got(x)($1)
1066; MIPS32-NEXT:  $BB4_1: # %entry
1067; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
1068; MIPS32-NEXT:    ll $2, 0($1)
1069; MIPS32-NEXT:    and $3, $2, $4
1070; MIPS32-NEXT:    sc $3, 0($1)
1071; MIPS32-NEXT:    beqz $3, $BB4_1
1072; MIPS32-NEXT:    nop
1073; MIPS32-NEXT:  # %bb.2: # %entry
1074; MIPS32-NEXT:    jr $ra
1075; MIPS32-NEXT:    nop
1076;
1077; MIPS32O0-LABEL: AtomicLoadAnd32:
1078; MIPS32O0:       # %bb.0: # %entry
1079; MIPS32O0-NEXT:    lui $2, %hi(_gp_disp)
1080; MIPS32O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
1081; MIPS32O0-NEXT:    addu $1, $2, $25
1082; MIPS32O0-NEXT:    lw $3, %got(x)($1)
1083; MIPS32O0-NEXT:  $BB4_1: # %entry
1084; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
1085; MIPS32O0-NEXT:    ll $2, 0($3)
1086; MIPS32O0-NEXT:    and $1, $2, $4
1087; MIPS32O0-NEXT:    sc $1, 0($3)
1088; MIPS32O0-NEXT:    beqz $1, $BB4_1
1089; MIPS32O0-NEXT:    nop
1090; MIPS32O0-NEXT:  # %bb.2: # %entry
1091; MIPS32O0-NEXT:    jr $ra
1092; MIPS32O0-NEXT:    nop
1093;
1094; MIPS32R2-LABEL: AtomicLoadAnd32:
1095; MIPS32R2:       # %bb.0: # %entry
1096; MIPS32R2-NEXT:    lui $2, %hi(_gp_disp)
1097; MIPS32R2-NEXT:    addiu $2, $2, %lo(_gp_disp)
1098; MIPS32R2-NEXT:    addu $1, $2, $25
1099; MIPS32R2-NEXT:    lw $1, %got(x)($1)
1100; MIPS32R2-NEXT:  $BB4_1: # %entry
1101; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
1102; MIPS32R2-NEXT:    ll $2, 0($1)
1103; MIPS32R2-NEXT:    and $3, $2, $4
1104; MIPS32R2-NEXT:    sc $3, 0($1)
1105; MIPS32R2-NEXT:    beqz $3, $BB4_1
1106; MIPS32R2-NEXT:    nop
1107; MIPS32R2-NEXT:  # %bb.2: # %entry
1108; MIPS32R2-NEXT:    jr $ra
1109; MIPS32R2-NEXT:    nop
1110;
1111; MIPS32R6-LABEL: AtomicLoadAnd32:
1112; MIPS32R6:       # %bb.0: # %entry
1113; MIPS32R6-NEXT:    lui $2, %hi(_gp_disp)
1114; MIPS32R6-NEXT:    addiu $2, $2, %lo(_gp_disp)
1115; MIPS32R6-NEXT:    addu $1, $2, $25
1116; MIPS32R6-NEXT:    lw $1, %got(x)($1)
1117; MIPS32R6-NEXT:  $BB4_1: # %entry
1118; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
1119; MIPS32R6-NEXT:    ll $2, 0($1)
1120; MIPS32R6-NEXT:    and $3, $2, $4
1121; MIPS32R6-NEXT:    sc $3, 0($1)
1122; MIPS32R6-NEXT:    beqzc $3, $BB4_1
1123; MIPS32R6-NEXT:    nop
1124; MIPS32R6-NEXT:  # %bb.2: # %entry
1125; MIPS32R6-NEXT:    jrc $ra
1126;
1127; MIPS32R6O0-LABEL: AtomicLoadAnd32:
1128; MIPS32R6O0:       # %bb.0: # %entry
1129; MIPS32R6O0-NEXT:    lui $2, %hi(_gp_disp)
1130; MIPS32R6O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
1131; MIPS32R6O0-NEXT:    addu $1, $2, $25
1132; MIPS32R6O0-NEXT:    lw $3, %got(x)($1)
1133; MIPS32R6O0-NEXT:  $BB4_1: # %entry
1134; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
1135; MIPS32R6O0-NEXT:    ll $2, 0($3)
1136; MIPS32R6O0-NEXT:    and $1, $2, $4
1137; MIPS32R6O0-NEXT:    sc $1, 0($3)
1138; MIPS32R6O0-NEXT:    beqzc $1, $BB4_1
1139; MIPS32R6O0-NEXT:    nop
1140; MIPS32R6O0-NEXT:  # %bb.2: # %entry
1141; MIPS32R6O0-NEXT:    jrc $ra
1142;
1143; MIPS4-LABEL: AtomicLoadAnd32:
1144; MIPS4:       # %bb.0: # %entry
1145; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAnd32)))
1146; MIPS4-NEXT:    daddu $1, $1, $25
1147; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAnd32)))
1148; MIPS4-NEXT:    ld $1, %got_disp(x)($1)
1149; MIPS4-NEXT:  .LBB4_1: # %entry
1150; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
1151; MIPS4-NEXT:    ll $2, 0($1)
1152; MIPS4-NEXT:    and $3, $2, $4
1153; MIPS4-NEXT:    sc $3, 0($1)
1154; MIPS4-NEXT:    beqz $3, .LBB4_1
1155; MIPS4-NEXT:    nop
1156; MIPS4-NEXT:  # %bb.2: # %entry
1157; MIPS4-NEXT:    jr $ra
1158; MIPS4-NEXT:    nop
1159;
1160; MIPS64-LABEL: AtomicLoadAnd32:
1161; MIPS64:       # %bb.0: # %entry
1162; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAnd32)))
1163; MIPS64-NEXT:    daddu $1, $1, $25
1164; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAnd32)))
1165; MIPS64-NEXT:    ld $1, %got_disp(x)($1)
1166; MIPS64-NEXT:  .LBB4_1: # %entry
1167; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
1168; MIPS64-NEXT:    ll $2, 0($1)
1169; MIPS64-NEXT:    and $3, $2, $4
1170; MIPS64-NEXT:    sc $3, 0($1)
1171; MIPS64-NEXT:    beqz $3, .LBB4_1
1172; MIPS64-NEXT:    nop
1173; MIPS64-NEXT:  # %bb.2: # %entry
1174; MIPS64-NEXT:    jr $ra
1175; MIPS64-NEXT:    nop
1176;
1177; MIPS64R2-LABEL: AtomicLoadAnd32:
1178; MIPS64R2:       # %bb.0: # %entry
1179; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAnd32)))
1180; MIPS64R2-NEXT:    daddu $1, $1, $25
1181; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAnd32)))
1182; MIPS64R2-NEXT:    ld $1, %got_disp(x)($1)
1183; MIPS64R2-NEXT:  .LBB4_1: # %entry
1184; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
1185; MIPS64R2-NEXT:    ll $2, 0($1)
1186; MIPS64R2-NEXT:    and $3, $2, $4
1187; MIPS64R2-NEXT:    sc $3, 0($1)
1188; MIPS64R2-NEXT:    beqz $3, .LBB4_1
1189; MIPS64R2-NEXT:    nop
1190; MIPS64R2-NEXT:  # %bb.2: # %entry
1191; MIPS64R2-NEXT:    jr $ra
1192; MIPS64R2-NEXT:    nop
1193;
1194; MIPS64R6-LABEL: AtomicLoadAnd32:
1195; MIPS64R6:       # %bb.0: # %entry
1196; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAnd32)))
1197; MIPS64R6-NEXT:    daddu $1, $1, $25
1198; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAnd32)))
1199; MIPS64R6-NEXT:    ld $1, %got_disp(x)($1)
1200; MIPS64R6-NEXT:  .LBB4_1: # %entry
1201; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
1202; MIPS64R6-NEXT:    ll $2, 0($1)
1203; MIPS64R6-NEXT:    and $3, $2, $4
1204; MIPS64R6-NEXT:    sc $3, 0($1)
1205; MIPS64R6-NEXT:    beqzc $3, .LBB4_1
1206; MIPS64R6-NEXT:    nop
1207; MIPS64R6-NEXT:  # %bb.2: # %entry
1208; MIPS64R6-NEXT:    jrc $ra
1209;
1210; MIPS64R6O0-LABEL: AtomicLoadAnd32:
1211; MIPS64R6O0:       # %bb.0: # %entry
1212; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAnd32)))
1213; MIPS64R6O0-NEXT:    daddu $1, $1, $25
1214; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAnd32)))
1215; MIPS64R6O0-NEXT:    # kill: def $a0 killed $a0 killed $a0_64
1216; MIPS64R6O0-NEXT:    ld $3, %got_disp(x)($1)
1217; MIPS64R6O0-NEXT:  .LBB4_1: # %entry
1218; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
1219; MIPS64R6O0-NEXT:    ll $2, 0($3)
1220; MIPS64R6O0-NEXT:    and $1, $2, $4
1221; MIPS64R6O0-NEXT:    sc $1, 0($3)
1222; MIPS64R6O0-NEXT:    beqzc $1, .LBB4_1
1223; MIPS64R6O0-NEXT:    nop
1224; MIPS64R6O0-NEXT:  # %bb.2: # %entry
1225; MIPS64R6O0-NEXT:    jrc $ra
1226;
1227; MM32-LABEL: AtomicLoadAnd32:
1228; MM32:       # %bb.0: # %entry
1229; MM32-NEXT:    lui $2, %hi(_gp_disp)
1230; MM32-NEXT:    addiu $2, $2, %lo(_gp_disp)
1231; MM32-NEXT:    addu $2, $2, $25
1232; MM32-NEXT:    lw $1, %got(x)($2)
1233; MM32-NEXT:  $BB4_1: # %entry
1234; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
1235; MM32-NEXT:    ll $2, 0($1)
1236; MM32-NEXT:    and $3, $2, $4
1237; MM32-NEXT:    sc $3, 0($1)
1238; MM32-NEXT:    beqzc $3, $BB4_1
1239; MM32-NEXT:  # %bb.2: # %entry
1240; MM32-NEXT:    jrc $ra
1241;
1242; O1-LABEL: AtomicLoadAnd32:
1243; O1:       # %bb.0: # %entry
1244; O1-NEXT:    lui $2, %hi(_gp_disp)
1245; O1-NEXT:    addiu $2, $2, %lo(_gp_disp)
1246; O1-NEXT:    addu $1, $2, $25
1247; O1-NEXT:    lw $1, %got(x)($1)
1248; O1-NEXT:  $BB4_1: # %entry
1249; O1-NEXT:    # =>This Inner Loop Header: Depth=1
1250; O1-NEXT:    ll $2, 0($1)
1251; O1-NEXT:    and $3, $2, $4
1252; O1-NEXT:    sc $3, 0($1)
1253; O1-NEXT:    beqz $3, $BB4_1
1254; O1-NEXT:    nop
1255; O1-NEXT:  # %bb.2: # %entry
1256; O1-NEXT:    jr $ra
1257; O1-NEXT:    nop
1258;
1259; O2-LABEL: AtomicLoadAnd32:
1260; O2:       # %bb.0: # %entry
1261; O2-NEXT:    lui $2, %hi(_gp_disp)
1262; O2-NEXT:    addiu $2, $2, %lo(_gp_disp)
1263; O2-NEXT:    addu $1, $2, $25
1264; O2-NEXT:    lw $1, %got(x)($1)
1265; O2-NEXT:  $BB4_1: # %entry
1266; O2-NEXT:    # =>This Inner Loop Header: Depth=1
1267; O2-NEXT:    ll $2, 0($1)
1268; O2-NEXT:    and $3, $2, $4
1269; O2-NEXT:    sc $3, 0($1)
1270; O2-NEXT:    beqz $3, $BB4_1
1271; O2-NEXT:    nop
1272; O2-NEXT:  # %bb.2: # %entry
1273; O2-NEXT:    jr $ra
1274; O2-NEXT:    nop
1275;
1276; O3-LABEL: AtomicLoadAnd32:
1277; O3:       # %bb.0: # %entry
1278; O3-NEXT:    lui $2, %hi(_gp_disp)
1279; O3-NEXT:    addiu $2, $2, %lo(_gp_disp)
1280; O3-NEXT:    addu $1, $2, $25
1281; O3-NEXT:    lw $1, %got(x)($1)
1282; O3-NEXT:  $BB4_1: # %entry
1283; O3-NEXT:    # =>This Inner Loop Header: Depth=1
1284; O3-NEXT:    ll $2, 0($1)
1285; O3-NEXT:    and $3, $2, $4
1286; O3-NEXT:    sc $3, 0($1)
1287; O3-NEXT:    beqz $3, $BB4_1
1288; O3-NEXT:    nop
1289; O3-NEXT:  # %bb.2: # %entry
1290; O3-NEXT:    jr $ra
1291; O3-NEXT:    nop
1292;
1293; MIPS32EB-LABEL: AtomicLoadAnd32:
1294; MIPS32EB:       # %bb.0: # %entry
1295; MIPS32EB-NEXT:    lui $2, %hi(_gp_disp)
1296; MIPS32EB-NEXT:    addiu $2, $2, %lo(_gp_disp)
1297; MIPS32EB-NEXT:    addu $1, $2, $25
1298; MIPS32EB-NEXT:    lw $1, %got(x)($1)
1299; MIPS32EB-NEXT:  $BB4_1: # %entry
1300; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
1301; MIPS32EB-NEXT:    ll $2, 0($1)
1302; MIPS32EB-NEXT:    and $3, $2, $4
1303; MIPS32EB-NEXT:    sc $3, 0($1)
1304; MIPS32EB-NEXT:    beqz $3, $BB4_1
1305; MIPS32EB-NEXT:    nop
1306; MIPS32EB-NEXT:  # %bb.2: # %entry
1307; MIPS32EB-NEXT:    jr $ra
1308; MIPS32EB-NEXT:    nop
1309entry:
1310  %0 = atomicrmw and i32* @x, i32 %incr monotonic
1311  ret i32 %0
1312}
1313
1314define i32 @AtomicLoadNand32(i32 signext %incr) nounwind {
1315; MIPS32-LABEL: AtomicLoadNand32:
1316; MIPS32:       # %bb.0: # %entry
1317; MIPS32-NEXT:    lui $2, %hi(_gp_disp)
1318; MIPS32-NEXT:    addiu $2, $2, %lo(_gp_disp)
1319; MIPS32-NEXT:    addu $1, $2, $25
1320; MIPS32-NEXT:    lw $1, %got(x)($1)
1321; MIPS32-NEXT:  $BB5_1: # %entry
1322; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
1323; MIPS32-NEXT:    ll $2, 0($1)
1324; MIPS32-NEXT:    and $3, $2, $4
1325; MIPS32-NEXT:    nor $3, $zero, $3
1326; MIPS32-NEXT:    sc $3, 0($1)
1327; MIPS32-NEXT:    beqz $3, $BB5_1
1328; MIPS32-NEXT:    nop
1329; MIPS32-NEXT:  # %bb.2: # %entry
1330; MIPS32-NEXT:    jr $ra
1331; MIPS32-NEXT:    nop
1332;
1333; MIPS32O0-LABEL: AtomicLoadNand32:
1334; MIPS32O0:       # %bb.0: # %entry
1335; MIPS32O0-NEXT:    lui $2, %hi(_gp_disp)
1336; MIPS32O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
1337; MIPS32O0-NEXT:    addu $1, $2, $25
1338; MIPS32O0-NEXT:    lw $3, %got(x)($1)
1339; MIPS32O0-NEXT:  $BB5_1: # %entry
1340; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
1341; MIPS32O0-NEXT:    ll $2, 0($3)
1342; MIPS32O0-NEXT:    and $1, $2, $4
1343; MIPS32O0-NEXT:    nor $1, $zero, $1
1344; MIPS32O0-NEXT:    sc $1, 0($3)
1345; MIPS32O0-NEXT:    beqz $1, $BB5_1
1346; MIPS32O0-NEXT:    nop
1347; MIPS32O0-NEXT:  # %bb.2: # %entry
1348; MIPS32O0-NEXT:    jr $ra
1349; MIPS32O0-NEXT:    nop
1350;
1351; MIPS32R2-LABEL: AtomicLoadNand32:
1352; MIPS32R2:       # %bb.0: # %entry
1353; MIPS32R2-NEXT:    lui $2, %hi(_gp_disp)
1354; MIPS32R2-NEXT:    addiu $2, $2, %lo(_gp_disp)
1355; MIPS32R2-NEXT:    addu $1, $2, $25
1356; MIPS32R2-NEXT:    lw $1, %got(x)($1)
1357; MIPS32R2-NEXT:  $BB5_1: # %entry
1358; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
1359; MIPS32R2-NEXT:    ll $2, 0($1)
1360; MIPS32R2-NEXT:    and $3, $2, $4
1361; MIPS32R2-NEXT:    nor $3, $zero, $3
1362; MIPS32R2-NEXT:    sc $3, 0($1)
1363; MIPS32R2-NEXT:    beqz $3, $BB5_1
1364; MIPS32R2-NEXT:    nop
1365; MIPS32R2-NEXT:  # %bb.2: # %entry
1366; MIPS32R2-NEXT:    jr $ra
1367; MIPS32R2-NEXT:    nop
1368;
1369; MIPS32R6-LABEL: AtomicLoadNand32:
1370; MIPS32R6:       # %bb.0: # %entry
1371; MIPS32R6-NEXT:    lui $2, %hi(_gp_disp)
1372; MIPS32R6-NEXT:    addiu $2, $2, %lo(_gp_disp)
1373; MIPS32R6-NEXT:    addu $1, $2, $25
1374; MIPS32R6-NEXT:    lw $1, %got(x)($1)
1375; MIPS32R6-NEXT:  $BB5_1: # %entry
1376; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
1377; MIPS32R6-NEXT:    ll $2, 0($1)
1378; MIPS32R6-NEXT:    and $3, $2, $4
1379; MIPS32R6-NEXT:    nor $3, $zero, $3
1380; MIPS32R6-NEXT:    sc $3, 0($1)
1381; MIPS32R6-NEXT:    beqzc $3, $BB5_1
1382; MIPS32R6-NEXT:    nop
1383; MIPS32R6-NEXT:  # %bb.2: # %entry
1384; MIPS32R6-NEXT:    jrc $ra
1385;
1386; MIPS32R6O0-LABEL: AtomicLoadNand32:
1387; MIPS32R6O0:       # %bb.0: # %entry
1388; MIPS32R6O0-NEXT:    lui $2, %hi(_gp_disp)
1389; MIPS32R6O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
1390; MIPS32R6O0-NEXT:    addu $1, $2, $25
1391; MIPS32R6O0-NEXT:    lw $3, %got(x)($1)
1392; MIPS32R6O0-NEXT:  $BB5_1: # %entry
1393; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
1394; MIPS32R6O0-NEXT:    ll $2, 0($3)
1395; MIPS32R6O0-NEXT:    and $1, $2, $4
1396; MIPS32R6O0-NEXT:    nor $1, $zero, $1
1397; MIPS32R6O0-NEXT:    sc $1, 0($3)
1398; MIPS32R6O0-NEXT:    beqzc $1, $BB5_1
1399; MIPS32R6O0-NEXT:    nop
1400; MIPS32R6O0-NEXT:  # %bb.2: # %entry
1401; MIPS32R6O0-NEXT:    jrc $ra
1402;
1403; MIPS4-LABEL: AtomicLoadNand32:
1404; MIPS4:       # %bb.0: # %entry
1405; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand32)))
1406; MIPS4-NEXT:    daddu $1, $1, $25
1407; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand32)))
1408; MIPS4-NEXT:    ld $1, %got_disp(x)($1)
1409; MIPS4-NEXT:  .LBB5_1: # %entry
1410; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
1411; MIPS4-NEXT:    ll $2, 0($1)
1412; MIPS4-NEXT:    and $3, $2, $4
1413; MIPS4-NEXT:    nor $3, $zero, $3
1414; MIPS4-NEXT:    sc $3, 0($1)
1415; MIPS4-NEXT:    beqz $3, .LBB5_1
1416; MIPS4-NEXT:    nop
1417; MIPS4-NEXT:  # %bb.2: # %entry
1418; MIPS4-NEXT:    jr $ra
1419; MIPS4-NEXT:    nop
1420;
1421; MIPS64-LABEL: AtomicLoadNand32:
1422; MIPS64:       # %bb.0: # %entry
1423; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand32)))
1424; MIPS64-NEXT:    daddu $1, $1, $25
1425; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand32)))
1426; MIPS64-NEXT:    ld $1, %got_disp(x)($1)
1427; MIPS64-NEXT:  .LBB5_1: # %entry
1428; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
1429; MIPS64-NEXT:    ll $2, 0($1)
1430; MIPS64-NEXT:    and $3, $2, $4
1431; MIPS64-NEXT:    nor $3, $zero, $3
1432; MIPS64-NEXT:    sc $3, 0($1)
1433; MIPS64-NEXT:    beqz $3, .LBB5_1
1434; MIPS64-NEXT:    nop
1435; MIPS64-NEXT:  # %bb.2: # %entry
1436; MIPS64-NEXT:    jr $ra
1437; MIPS64-NEXT:    nop
1438;
1439; MIPS64R2-LABEL: AtomicLoadNand32:
1440; MIPS64R2:       # %bb.0: # %entry
1441; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand32)))
1442; MIPS64R2-NEXT:    daddu $1, $1, $25
1443; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand32)))
1444; MIPS64R2-NEXT:    ld $1, %got_disp(x)($1)
1445; MIPS64R2-NEXT:  .LBB5_1: # %entry
1446; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
1447; MIPS64R2-NEXT:    ll $2, 0($1)
1448; MIPS64R2-NEXT:    and $3, $2, $4
1449; MIPS64R2-NEXT:    nor $3, $zero, $3
1450; MIPS64R2-NEXT:    sc $3, 0($1)
1451; MIPS64R2-NEXT:    beqz $3, .LBB5_1
1452; MIPS64R2-NEXT:    nop
1453; MIPS64R2-NEXT:  # %bb.2: # %entry
1454; MIPS64R2-NEXT:    jr $ra
1455; MIPS64R2-NEXT:    nop
1456;
1457; MIPS64R6-LABEL: AtomicLoadNand32:
1458; MIPS64R6:       # %bb.0: # %entry
1459; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand32)))
1460; MIPS64R6-NEXT:    daddu $1, $1, $25
1461; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand32)))
1462; MIPS64R6-NEXT:    ld $1, %got_disp(x)($1)
1463; MIPS64R6-NEXT:  .LBB5_1: # %entry
1464; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
1465; MIPS64R6-NEXT:    ll $2, 0($1)
1466; MIPS64R6-NEXT:    and $3, $2, $4
1467; MIPS64R6-NEXT:    nor $3, $zero, $3
1468; MIPS64R6-NEXT:    sc $3, 0($1)
1469; MIPS64R6-NEXT:    beqzc $3, .LBB5_1
1470; MIPS64R6-NEXT:    nop
1471; MIPS64R6-NEXT:  # %bb.2: # %entry
1472; MIPS64R6-NEXT:    jrc $ra
1473;
1474; MIPS64R6O0-LABEL: AtomicLoadNand32:
1475; MIPS64R6O0:       # %bb.0: # %entry
1476; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand32)))
1477; MIPS64R6O0-NEXT:    daddu $1, $1, $25
1478; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand32)))
1479; MIPS64R6O0-NEXT:    # kill: def $a0 killed $a0 killed $a0_64
1480; MIPS64R6O0-NEXT:    ld $3, %got_disp(x)($1)
1481; MIPS64R6O0-NEXT:  .LBB5_1: # %entry
1482; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
1483; MIPS64R6O0-NEXT:    ll $2, 0($3)
1484; MIPS64R6O0-NEXT:    and $1, $2, $4
1485; MIPS64R6O0-NEXT:    nor $1, $zero, $1
1486; MIPS64R6O0-NEXT:    sc $1, 0($3)
1487; MIPS64R6O0-NEXT:    beqzc $1, .LBB5_1
1488; MIPS64R6O0-NEXT:    nop
1489; MIPS64R6O0-NEXT:  # %bb.2: # %entry
1490; MIPS64R6O0-NEXT:    jrc $ra
1491;
1492; MM32-LABEL: AtomicLoadNand32:
1493; MM32:       # %bb.0: # %entry
1494; MM32-NEXT:    lui $2, %hi(_gp_disp)
1495; MM32-NEXT:    addiu $2, $2, %lo(_gp_disp)
1496; MM32-NEXT:    addu $2, $2, $25
1497; MM32-NEXT:    lw $1, %got(x)($2)
1498; MM32-NEXT:  $BB5_1: # %entry
1499; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
1500; MM32-NEXT:    ll $2, 0($1)
1501; MM32-NEXT:    and $3, $2, $4
1502; MM32-NEXT:    nor $3, $zero, $3
1503; MM32-NEXT:    sc $3, 0($1)
1504; MM32-NEXT:    beqzc $3, $BB5_1
1505; MM32-NEXT:  # %bb.2: # %entry
1506; MM32-NEXT:    jrc $ra
1507;
1508; O1-LABEL: AtomicLoadNand32:
1509; O1:       # %bb.0: # %entry
1510; O1-NEXT:    lui $2, %hi(_gp_disp)
1511; O1-NEXT:    addiu $2, $2, %lo(_gp_disp)
1512; O1-NEXT:    addu $1, $2, $25
1513; O1-NEXT:    lw $1, %got(x)($1)
1514; O1-NEXT:  $BB5_1: # %entry
1515; O1-NEXT:    # =>This Inner Loop Header: Depth=1
1516; O1-NEXT:    ll $2, 0($1)
1517; O1-NEXT:    and $3, $2, $4
1518; O1-NEXT:    nor $3, $zero, $3
1519; O1-NEXT:    sc $3, 0($1)
1520; O1-NEXT:    beqz $3, $BB5_1
1521; O1-NEXT:    nop
1522; O1-NEXT:  # %bb.2: # %entry
1523; O1-NEXT:    jr $ra
1524; O1-NEXT:    nop
1525;
1526; O2-LABEL: AtomicLoadNand32:
1527; O2:       # %bb.0: # %entry
1528; O2-NEXT:    lui $2, %hi(_gp_disp)
1529; O2-NEXT:    addiu $2, $2, %lo(_gp_disp)
1530; O2-NEXT:    addu $1, $2, $25
1531; O2-NEXT:    lw $1, %got(x)($1)
1532; O2-NEXT:  $BB5_1: # %entry
1533; O2-NEXT:    # =>This Inner Loop Header: Depth=1
1534; O2-NEXT:    ll $2, 0($1)
1535; O2-NEXT:    and $3, $2, $4
1536; O2-NEXT:    nor $3, $zero, $3
1537; O2-NEXT:    sc $3, 0($1)
1538; O2-NEXT:    beqz $3, $BB5_1
1539; O2-NEXT:    nop
1540; O2-NEXT:  # %bb.2: # %entry
1541; O2-NEXT:    jr $ra
1542; O2-NEXT:    nop
1543;
1544; O3-LABEL: AtomicLoadNand32:
1545; O3:       # %bb.0: # %entry
1546; O3-NEXT:    lui $2, %hi(_gp_disp)
1547; O3-NEXT:    addiu $2, $2, %lo(_gp_disp)
1548; O3-NEXT:    addu $1, $2, $25
1549; O3-NEXT:    lw $1, %got(x)($1)
1550; O3-NEXT:  $BB5_1: # %entry
1551; O3-NEXT:    # =>This Inner Loop Header: Depth=1
1552; O3-NEXT:    ll $2, 0($1)
1553; O3-NEXT:    and $3, $2, $4
1554; O3-NEXT:    nor $3, $zero, $3
1555; O3-NEXT:    sc $3, 0($1)
1556; O3-NEXT:    beqz $3, $BB5_1
1557; O3-NEXT:    nop
1558; O3-NEXT:  # %bb.2: # %entry
1559; O3-NEXT:    jr $ra
1560; O3-NEXT:    nop
1561;
1562; MIPS32EB-LABEL: AtomicLoadNand32:
1563; MIPS32EB:       # %bb.0: # %entry
1564; MIPS32EB-NEXT:    lui $2, %hi(_gp_disp)
1565; MIPS32EB-NEXT:    addiu $2, $2, %lo(_gp_disp)
1566; MIPS32EB-NEXT:    addu $1, $2, $25
1567; MIPS32EB-NEXT:    lw $1, %got(x)($1)
1568; MIPS32EB-NEXT:  $BB5_1: # %entry
1569; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
1570; MIPS32EB-NEXT:    ll $2, 0($1)
1571; MIPS32EB-NEXT:    and $3, $2, $4
1572; MIPS32EB-NEXT:    nor $3, $zero, $3
1573; MIPS32EB-NEXT:    sc $3, 0($1)
1574; MIPS32EB-NEXT:    beqz $3, $BB5_1
1575; MIPS32EB-NEXT:    nop
1576; MIPS32EB-NEXT:  # %bb.2: # %entry
1577; MIPS32EB-NEXT:    jr $ra
1578; MIPS32EB-NEXT:    nop
1579entry:
1580  %0 = atomicrmw nand i32* @x, i32 %incr monotonic
1581  ret i32 %0
1582
1583}
1584
1585define i32 @AtomicSwap32(i32 signext %newval) nounwind {
1586; MIPS32-LABEL: AtomicSwap32:
1587; MIPS32:       # %bb.0: # %entry
1588; MIPS32-NEXT:    lui $2, %hi(_gp_disp)
1589; MIPS32-NEXT:    addiu $2, $2, %lo(_gp_disp)
1590; MIPS32-NEXT:    addiu $sp, $sp, -8
1591; MIPS32-NEXT:    addu $1, $2, $25
1592; MIPS32-NEXT:    sw $4, 4($sp)
1593; MIPS32-NEXT:    lw $1, %got(x)($1)
1594; MIPS32-NEXT:  $BB6_1: # %entry
1595; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
1596; MIPS32-NEXT:    ll $2, 0($1)
1597; MIPS32-NEXT:    move $3, $4
1598; MIPS32-NEXT:    sc $3, 0($1)
1599; MIPS32-NEXT:    beqz $3, $BB6_1
1600; MIPS32-NEXT:    nop
1601; MIPS32-NEXT:  # %bb.2: # %entry
1602; MIPS32-NEXT:    jr $ra
1603; MIPS32-NEXT:    addiu $sp, $sp, 8
1604;
1605; MIPS32O0-LABEL: AtomicSwap32:
1606; MIPS32O0:       # %bb.0: # %entry
1607; MIPS32O0-NEXT:    lui $2, %hi(_gp_disp)
1608; MIPS32O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
1609; MIPS32O0-NEXT:    addiu $sp, $sp, -8
1610; MIPS32O0-NEXT:    addu $1, $2, $25
1611; MIPS32O0-NEXT:    sw $4, 4($sp)
1612; MIPS32O0-NEXT:    lw $4, 4($sp)
1613; MIPS32O0-NEXT:    lw $3, %got(x)($1)
1614; MIPS32O0-NEXT:  $BB6_1: # %entry
1615; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
1616; MIPS32O0-NEXT:    ll $2, 0($3)
1617; MIPS32O0-NEXT:    move $1, $4
1618; MIPS32O0-NEXT:    sc $1, 0($3)
1619; MIPS32O0-NEXT:    beqz $1, $BB6_1
1620; MIPS32O0-NEXT:    nop
1621; MIPS32O0-NEXT:  # %bb.2: # %entry
1622; MIPS32O0-NEXT:    addiu $sp, $sp, 8
1623; MIPS32O0-NEXT:    jr $ra
1624; MIPS32O0-NEXT:    nop
1625;
1626; MIPS32R2-LABEL: AtomicSwap32:
1627; MIPS32R2:       # %bb.0: # %entry
1628; MIPS32R2-NEXT:    lui $2, %hi(_gp_disp)
1629; MIPS32R2-NEXT:    addiu $2, $2, %lo(_gp_disp)
1630; MIPS32R2-NEXT:    addiu $sp, $sp, -8
1631; MIPS32R2-NEXT:    addu $1, $2, $25
1632; MIPS32R2-NEXT:    sw $4, 4($sp)
1633; MIPS32R2-NEXT:    lw $1, %got(x)($1)
1634; MIPS32R2-NEXT:  $BB6_1: # %entry
1635; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
1636; MIPS32R2-NEXT:    ll $2, 0($1)
1637; MIPS32R2-NEXT:    move $3, $4
1638; MIPS32R2-NEXT:    sc $3, 0($1)
1639; MIPS32R2-NEXT:    beqz $3, $BB6_1
1640; MIPS32R2-NEXT:    nop
1641; MIPS32R2-NEXT:  # %bb.2: # %entry
1642; MIPS32R2-NEXT:    jr $ra
1643; MIPS32R2-NEXT:    addiu $sp, $sp, 8
1644;
1645; MIPS32R6-LABEL: AtomicSwap32:
1646; MIPS32R6:       # %bb.0: # %entry
1647; MIPS32R6-NEXT:    lui $2, %hi(_gp_disp)
1648; MIPS32R6-NEXT:    addiu $2, $2, %lo(_gp_disp)
1649; MIPS32R6-NEXT:    addiu $sp, $sp, -8
1650; MIPS32R6-NEXT:    addu $1, $2, $25
1651; MIPS32R6-NEXT:    sw $4, 4($sp)
1652; MIPS32R6-NEXT:    lw $1, %got(x)($1)
1653; MIPS32R6-NEXT:  $BB6_1: # %entry
1654; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
1655; MIPS32R6-NEXT:    ll $2, 0($1)
1656; MIPS32R6-NEXT:    move $3, $4
1657; MIPS32R6-NEXT:    sc $3, 0($1)
1658; MIPS32R6-NEXT:    beqzc $3, $BB6_1
1659; MIPS32R6-NEXT:    nop
1660; MIPS32R6-NEXT:  # %bb.2: # %entry
1661; MIPS32R6-NEXT:    jr $ra
1662; MIPS32R6-NEXT:    addiu $sp, $sp, 8
1663;
1664; MIPS32R6O0-LABEL: AtomicSwap32:
1665; MIPS32R6O0:       # %bb.0: # %entry
1666; MIPS32R6O0-NEXT:    lui $2, %hi(_gp_disp)
1667; MIPS32R6O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
1668; MIPS32R6O0-NEXT:    addiu $sp, $sp, -8
1669; MIPS32R6O0-NEXT:    addu $1, $2, $25
1670; MIPS32R6O0-NEXT:    sw $4, 4($sp)
1671; MIPS32R6O0-NEXT:    lw $4, 4($sp)
1672; MIPS32R6O0-NEXT:    lw $3, %got(x)($1)
1673; MIPS32R6O0-NEXT:  $BB6_1: # %entry
1674; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
1675; MIPS32R6O0-NEXT:    ll $2, 0($3)
1676; MIPS32R6O0-NEXT:    move $1, $4
1677; MIPS32R6O0-NEXT:    sc $1, 0($3)
1678; MIPS32R6O0-NEXT:    beqzc $1, $BB6_1
1679; MIPS32R6O0-NEXT:  # %bb.2: # %entry
1680; MIPS32R6O0-NEXT:    addiu $sp, $sp, 8
1681; MIPS32R6O0-NEXT:    jrc $ra
1682;
1683; MIPS4-LABEL: AtomicSwap32:
1684; MIPS4:       # %bb.0: # %entry
1685; MIPS4-NEXT:    daddiu $sp, $sp, -16
1686; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap32)))
1687; MIPS4-NEXT:    daddu $1, $1, $25
1688; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap32)))
1689; MIPS4-NEXT:    sw $4, 12($sp)
1690; MIPS4-NEXT:    ld $1, %got_disp(x)($1)
1691; MIPS4-NEXT:  .LBB6_1: # %entry
1692; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
1693; MIPS4-NEXT:    ll $2, 0($1)
1694; MIPS4-NEXT:    move $3, $4
1695; MIPS4-NEXT:    sc $3, 0($1)
1696; MIPS4-NEXT:    beqz $3, .LBB6_1
1697; MIPS4-NEXT:    nop
1698; MIPS4-NEXT:  # %bb.2: # %entry
1699; MIPS4-NEXT:    jr $ra
1700; MIPS4-NEXT:    daddiu $sp, $sp, 16
1701;
1702; MIPS64-LABEL: AtomicSwap32:
1703; MIPS64:       # %bb.0: # %entry
1704; MIPS64-NEXT:    daddiu $sp, $sp, -16
1705; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap32)))
1706; MIPS64-NEXT:    daddu $1, $1, $25
1707; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap32)))
1708; MIPS64-NEXT:    sw $4, 12($sp)
1709; MIPS64-NEXT:    ld $1, %got_disp(x)($1)
1710; MIPS64-NEXT:  .LBB6_1: # %entry
1711; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
1712; MIPS64-NEXT:    ll $2, 0($1)
1713; MIPS64-NEXT:    move $3, $4
1714; MIPS64-NEXT:    sc $3, 0($1)
1715; MIPS64-NEXT:    beqz $3, .LBB6_1
1716; MIPS64-NEXT:    nop
1717; MIPS64-NEXT:  # %bb.2: # %entry
1718; MIPS64-NEXT:    jr $ra
1719; MIPS64-NEXT:    daddiu $sp, $sp, 16
1720;
1721; MIPS64R2-LABEL: AtomicSwap32:
1722; MIPS64R2:       # %bb.0: # %entry
1723; MIPS64R2-NEXT:    daddiu $sp, $sp, -16
1724; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap32)))
1725; MIPS64R2-NEXT:    daddu $1, $1, $25
1726; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap32)))
1727; MIPS64R2-NEXT:    sw $4, 12($sp)
1728; MIPS64R2-NEXT:    ld $1, %got_disp(x)($1)
1729; MIPS64R2-NEXT:  .LBB6_1: # %entry
1730; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
1731; MIPS64R2-NEXT:    ll $2, 0($1)
1732; MIPS64R2-NEXT:    move $3, $4
1733; MIPS64R2-NEXT:    sc $3, 0($1)
1734; MIPS64R2-NEXT:    beqz $3, .LBB6_1
1735; MIPS64R2-NEXT:    nop
1736; MIPS64R2-NEXT:  # %bb.2: # %entry
1737; MIPS64R2-NEXT:    jr $ra
1738; MIPS64R2-NEXT:    daddiu $sp, $sp, 16
1739;
1740; MIPS64R6-LABEL: AtomicSwap32:
1741; MIPS64R6:       # %bb.0: # %entry
1742; MIPS64R6-NEXT:    daddiu $sp, $sp, -16
1743; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap32)))
1744; MIPS64R6-NEXT:    daddu $1, $1, $25
1745; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap32)))
1746; MIPS64R6-NEXT:    sw $4, 12($sp)
1747; MIPS64R6-NEXT:    ld $1, %got_disp(x)($1)
1748; MIPS64R6-NEXT:  .LBB6_1: # %entry
1749; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
1750; MIPS64R6-NEXT:    ll $2, 0($1)
1751; MIPS64R6-NEXT:    move $3, $4
1752; MIPS64R6-NEXT:    sc $3, 0($1)
1753; MIPS64R6-NEXT:    beqzc $3, .LBB6_1
1754; MIPS64R6-NEXT:    nop
1755; MIPS64R6-NEXT:  # %bb.2: # %entry
1756; MIPS64R6-NEXT:    jr $ra
1757; MIPS64R6-NEXT:    daddiu $sp, $sp, 16
1758;
1759; MIPS64R6O0-LABEL: AtomicSwap32:
1760; MIPS64R6O0:       # %bb.0: # %entry
1761; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -16
1762; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap32)))
1763; MIPS64R6O0-NEXT:    daddu $1, $1, $25
1764; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap32)))
1765; MIPS64R6O0-NEXT:    move $2, $4
1766; MIPS64R6O0-NEXT:    sw $2, 12($sp)
1767; MIPS64R6O0-NEXT:    lw $4, 12($sp)
1768; MIPS64R6O0-NEXT:    ld $3, %got_disp(x)($1)
1769; MIPS64R6O0-NEXT:  .LBB6_1: # %entry
1770; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
1771; MIPS64R6O0-NEXT:    ll $2, 0($3)
1772; MIPS64R6O0-NEXT:    move $1, $4
1773; MIPS64R6O0-NEXT:    sc $1, 0($3)
1774; MIPS64R6O0-NEXT:    beqzc $1, .LBB6_1
1775; MIPS64R6O0-NEXT:  # %bb.2: # %entry
1776; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 16
1777; MIPS64R6O0-NEXT:    jrc $ra
1778;
1779; MM32-LABEL: AtomicSwap32:
1780; MM32:       # %bb.0: # %entry
1781; MM32-NEXT:    lui $2, %hi(_gp_disp)
1782; MM32-NEXT:    addiu $2, $2, %lo(_gp_disp)
1783; MM32-NEXT:    addiu $sp, $sp, -8
1784; MM32-NEXT:    addu $2, $2, $25
1785; MM32-NEXT:    sw $4, 4($sp)
1786; MM32-NEXT:    lw $1, %got(x)($2)
1787; MM32-NEXT:  $BB6_1: # %entry
1788; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
1789; MM32-NEXT:    ll $2, 0($1)
1790; MM32-NEXT:    or $3, $4, $zero
1791; MM32-NEXT:    sc $3, 0($1)
1792; MM32-NEXT:    beqzc $3, $BB6_1
1793; MM32-NEXT:  # %bb.2: # %entry
1794; MM32-NEXT:    addiusp 8
1795; MM32-NEXT:    jrc $ra
1796;
1797; O1-LABEL: AtomicSwap32:
1798; O1:       # %bb.0: # %entry
1799; O1-NEXT:    lui $2, %hi(_gp_disp)
1800; O1-NEXT:    addiu $2, $2, %lo(_gp_disp)
1801; O1-NEXT:    addiu $sp, $sp, -8
1802; O1-NEXT:    addu $1, $2, $25
1803; O1-NEXT:    sw $4, 4($sp)
1804; O1-NEXT:    lw $1, %got(x)($1)
1805; O1-NEXT:  $BB6_1: # %entry
1806; O1-NEXT:    # =>This Inner Loop Header: Depth=1
1807; O1-NEXT:    ll $2, 0($1)
1808; O1-NEXT:    move $3, $4
1809; O1-NEXT:    sc $3, 0($1)
1810; O1-NEXT:    beqz $3, $BB6_1
1811; O1-NEXT:    nop
1812; O1-NEXT:  # %bb.2: # %entry
1813; O1-NEXT:    jr $ra
1814; O1-NEXT:    addiu $sp, $sp, 8
1815;
1816; O2-LABEL: AtomicSwap32:
1817; O2:       # %bb.0: # %entry
1818; O2-NEXT:    lui $2, %hi(_gp_disp)
1819; O2-NEXT:    addiu $2, $2, %lo(_gp_disp)
1820; O2-NEXT:    addiu $sp, $sp, -8
1821; O2-NEXT:    addu $1, $2, $25
1822; O2-NEXT:    sw $4, 4($sp)
1823; O2-NEXT:    lw $1, %got(x)($1)
1824; O2-NEXT:  $BB6_1: # %entry
1825; O2-NEXT:    # =>This Inner Loop Header: Depth=1
1826; O2-NEXT:    ll $2, 0($1)
1827; O2-NEXT:    move $3, $4
1828; O2-NEXT:    sc $3, 0($1)
1829; O2-NEXT:    beqz $3, $BB6_1
1830; O2-NEXT:    nop
1831; O2-NEXT:  # %bb.2: # %entry
1832; O2-NEXT:    jr $ra
1833; O2-NEXT:    addiu $sp, $sp, 8
1834;
1835; O3-LABEL: AtomicSwap32:
1836; O3:       # %bb.0: # %entry
1837; O3-NEXT:    lui $2, %hi(_gp_disp)
1838; O3-NEXT:    addiu $2, $2, %lo(_gp_disp)
1839; O3-NEXT:    addiu $sp, $sp, -8
1840; O3-NEXT:    addu $1, $2, $25
1841; O3-NEXT:    sw $4, 4($sp)
1842; O3-NEXT:    lw $1, %got(x)($1)
1843; O3-NEXT:  $BB6_1: # %entry
1844; O3-NEXT:    # =>This Inner Loop Header: Depth=1
1845; O3-NEXT:    ll $2, 0($1)
1846; O3-NEXT:    move $3, $4
1847; O3-NEXT:    sc $3, 0($1)
1848; O3-NEXT:    beqz $3, $BB6_1
1849; O3-NEXT:    nop
1850; O3-NEXT:  # %bb.2: # %entry
1851; O3-NEXT:    jr $ra
1852; O3-NEXT:    addiu $sp, $sp, 8
1853;
1854; MIPS32EB-LABEL: AtomicSwap32:
1855; MIPS32EB:       # %bb.0: # %entry
1856; MIPS32EB-NEXT:    lui $2, %hi(_gp_disp)
1857; MIPS32EB-NEXT:    addiu $2, $2, %lo(_gp_disp)
1858; MIPS32EB-NEXT:    addiu $sp, $sp, -8
1859; MIPS32EB-NEXT:    addu $1, $2, $25
1860; MIPS32EB-NEXT:    sw $4, 4($sp)
1861; MIPS32EB-NEXT:    lw $1, %got(x)($1)
1862; MIPS32EB-NEXT:  $BB6_1: # %entry
1863; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
1864; MIPS32EB-NEXT:    ll $2, 0($1)
1865; MIPS32EB-NEXT:    move $3, $4
1866; MIPS32EB-NEXT:    sc $3, 0($1)
1867; MIPS32EB-NEXT:    beqz $3, $BB6_1
1868; MIPS32EB-NEXT:    nop
1869; MIPS32EB-NEXT:  # %bb.2: # %entry
1870; MIPS32EB-NEXT:    jr $ra
1871; MIPS32EB-NEXT:    addiu $sp, $sp, 8
1872entry:
1873  %newval.addr = alloca i32, align 4
1874  store i32 %newval, i32* %newval.addr, align 4
1875  %tmp = load i32, i32* %newval.addr, align 4
1876  %0 = atomicrmw xchg i32* @x, i32 %tmp monotonic
1877  ret i32 %0
1878
1879}
1880
1881define i32 @AtomicCmpSwap32(i32 signext %oldval, i32 signext %newval) nounwind {
1882; MIPS32-LABEL: AtomicCmpSwap32:
1883; MIPS32:       # %bb.0: # %entry
1884; MIPS32-NEXT:    lui $2, %hi(_gp_disp)
1885; MIPS32-NEXT:    addiu $2, $2, %lo(_gp_disp)
1886; MIPS32-NEXT:    addiu $sp, $sp, -8
1887; MIPS32-NEXT:    addu $1, $2, $25
1888; MIPS32-NEXT:    sw $5, 4($sp)
1889; MIPS32-NEXT:    lw $1, %got(x)($1)
1890; MIPS32-NEXT:  $BB7_1: # %entry
1891; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
1892; MIPS32-NEXT:    ll $2, 0($1)
1893; MIPS32-NEXT:    bne $2, $4, $BB7_3
1894; MIPS32-NEXT:    nop
1895; MIPS32-NEXT:  # %bb.2: # %entry
1896; MIPS32-NEXT:    # in Loop: Header=BB7_1 Depth=1
1897; MIPS32-NEXT:    move $3, $5
1898; MIPS32-NEXT:    sc $3, 0($1)
1899; MIPS32-NEXT:    beqz $3, $BB7_1
1900; MIPS32-NEXT:    nop
1901; MIPS32-NEXT:  $BB7_3: # %entry
1902; MIPS32-NEXT:    jr $ra
1903; MIPS32-NEXT:    addiu $sp, $sp, 8
1904;
1905; MIPS32O0-LABEL: AtomicCmpSwap32:
1906; MIPS32O0:       # %bb.0: # %entry
1907; MIPS32O0-NEXT:    lui $2, %hi(_gp_disp)
1908; MIPS32O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
1909; MIPS32O0-NEXT:    addiu $sp, $sp, -8
1910; MIPS32O0-NEXT:    addu $1, $2, $25
1911; MIPS32O0-NEXT:    sw $5, 4($sp)
1912; MIPS32O0-NEXT:    lw $6, 4($sp)
1913; MIPS32O0-NEXT:    lw $3, %got(x)($1)
1914; MIPS32O0-NEXT:    move $5, $4
1915; MIPS32O0-NEXT:  $BB7_1: # %entry
1916; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
1917; MIPS32O0-NEXT:    ll $2, 0($3)
1918; MIPS32O0-NEXT:    bne $2, $5, $BB7_3
1919; MIPS32O0-NEXT:    nop
1920; MIPS32O0-NEXT:  # %bb.2: # %entry
1921; MIPS32O0-NEXT:    # in Loop: Header=BB7_1 Depth=1
1922; MIPS32O0-NEXT:    move $1, $6
1923; MIPS32O0-NEXT:    sc $1, 0($3)
1924; MIPS32O0-NEXT:    beqz $1, $BB7_1
1925; MIPS32O0-NEXT:    nop
1926; MIPS32O0-NEXT:  $BB7_3: # %entry
1927; MIPS32O0-NEXT:    xor $1, $2, $4
1928; MIPS32O0-NEXT:    sltiu $1, $1, 1
1929; MIPS32O0-NEXT:    addiu $sp, $sp, 8
1930; MIPS32O0-NEXT:    jr $ra
1931; MIPS32O0-NEXT:    nop
1932;
1933; MIPS32R2-LABEL: AtomicCmpSwap32:
1934; MIPS32R2:       # %bb.0: # %entry
1935; MIPS32R2-NEXT:    lui $2, %hi(_gp_disp)
1936; MIPS32R2-NEXT:    addiu $2, $2, %lo(_gp_disp)
1937; MIPS32R2-NEXT:    addiu $sp, $sp, -8
1938; MIPS32R2-NEXT:    addu $1, $2, $25
1939; MIPS32R2-NEXT:    sw $5, 4($sp)
1940; MIPS32R2-NEXT:    lw $1, %got(x)($1)
1941; MIPS32R2-NEXT:  $BB7_1: # %entry
1942; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
1943; MIPS32R2-NEXT:    ll $2, 0($1)
1944; MIPS32R2-NEXT:    bne $2, $4, $BB7_3
1945; MIPS32R2-NEXT:    nop
1946; MIPS32R2-NEXT:  # %bb.2: # %entry
1947; MIPS32R2-NEXT:    # in Loop: Header=BB7_1 Depth=1
1948; MIPS32R2-NEXT:    move $3, $5
1949; MIPS32R2-NEXT:    sc $3, 0($1)
1950; MIPS32R2-NEXT:    beqz $3, $BB7_1
1951; MIPS32R2-NEXT:    nop
1952; MIPS32R2-NEXT:  $BB7_3: # %entry
1953; MIPS32R2-NEXT:    jr $ra
1954; MIPS32R2-NEXT:    addiu $sp, $sp, 8
1955;
1956; MIPS32R6-LABEL: AtomicCmpSwap32:
1957; MIPS32R6:       # %bb.0: # %entry
1958; MIPS32R6-NEXT:    lui $2, %hi(_gp_disp)
1959; MIPS32R6-NEXT:    addiu $2, $2, %lo(_gp_disp)
1960; MIPS32R6-NEXT:    addiu $sp, $sp, -8
1961; MIPS32R6-NEXT:    addu $1, $2, $25
1962; MIPS32R6-NEXT:    sw $5, 4($sp)
1963; MIPS32R6-NEXT:    lw $1, %got(x)($1)
1964; MIPS32R6-NEXT:  $BB7_1: # %entry
1965; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
1966; MIPS32R6-NEXT:    ll $2, 0($1)
1967; MIPS32R6-NEXT:    bnec $2, $4, $BB7_3
1968; MIPS32R6-NEXT:  # %bb.2: # %entry
1969; MIPS32R6-NEXT:    # in Loop: Header=BB7_1 Depth=1
1970; MIPS32R6-NEXT:    move $3, $5
1971; MIPS32R6-NEXT:    sc $3, 0($1)
1972; MIPS32R6-NEXT:    beqzc $3, $BB7_1
1973; MIPS32R6-NEXT:    nop
1974; MIPS32R6-NEXT:  $BB7_3: # %entry
1975; MIPS32R6-NEXT:    jr $ra
1976; MIPS32R6-NEXT:    addiu $sp, $sp, 8
1977;
1978; MIPS32R6O0-LABEL: AtomicCmpSwap32:
1979; MIPS32R6O0:       # %bb.0: # %entry
1980; MIPS32R6O0-NEXT:    lui $2, %hi(_gp_disp)
1981; MIPS32R6O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
1982; MIPS32R6O0-NEXT:    addiu $sp, $sp, -8
1983; MIPS32R6O0-NEXT:    addu $1, $2, $25
1984; MIPS32R6O0-NEXT:    sw $5, 4($sp)
1985; MIPS32R6O0-NEXT:    lw $5, 4($sp)
1986; MIPS32R6O0-NEXT:    lw $3, %got(x)($1)
1987; MIPS32R6O0-NEXT:  $BB7_1: # %entry
1988; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
1989; MIPS32R6O0-NEXT:    ll $2, 0($3)
1990; MIPS32R6O0-NEXT:    bnec $2, $4, $BB7_3
1991; MIPS32R6O0-NEXT:  # %bb.2: # %entry
1992; MIPS32R6O0-NEXT:    # in Loop: Header=BB7_1 Depth=1
1993; MIPS32R6O0-NEXT:    move $1, $5
1994; MIPS32R6O0-NEXT:    sc $1, 0($3)
1995; MIPS32R6O0-NEXT:    beqzc $1, $BB7_1
1996; MIPS32R6O0-NEXT:  $BB7_3: # %entry
1997; MIPS32R6O0-NEXT:    addiu $sp, $sp, 8
1998; MIPS32R6O0-NEXT:    jrc $ra
1999;
2000; MIPS4-LABEL: AtomicCmpSwap32:
2001; MIPS4:       # %bb.0: # %entry
2002; MIPS4-NEXT:    daddiu $sp, $sp, -16
2003; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap32)))
2004; MIPS4-NEXT:    daddu $1, $1, $25
2005; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap32)))
2006; MIPS4-NEXT:    sw $5, 12($sp)
2007; MIPS4-NEXT:    ld $1, %got_disp(x)($1)
2008; MIPS4-NEXT:  .LBB7_1: # %entry
2009; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
2010; MIPS4-NEXT:    ll $2, 0($1)
2011; MIPS4-NEXT:    bne $2, $4, .LBB7_3
2012; MIPS4-NEXT:    nop
2013; MIPS4-NEXT:  # %bb.2: # %entry
2014; MIPS4-NEXT:    # in Loop: Header=BB7_1 Depth=1
2015; MIPS4-NEXT:    move $3, $5
2016; MIPS4-NEXT:    sc $3, 0($1)
2017; MIPS4-NEXT:    beqz $3, .LBB7_1
2018; MIPS4-NEXT:    nop
2019; MIPS4-NEXT:  .LBB7_3: # %entry
2020; MIPS4-NEXT:    jr $ra
2021; MIPS4-NEXT:    daddiu $sp, $sp, 16
2022;
2023; MIPS64-LABEL: AtomicCmpSwap32:
2024; MIPS64:       # %bb.0: # %entry
2025; MIPS64-NEXT:    daddiu $sp, $sp, -16
2026; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap32)))
2027; MIPS64-NEXT:    daddu $1, $1, $25
2028; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap32)))
2029; MIPS64-NEXT:    sw $5, 12($sp)
2030; MIPS64-NEXT:    ld $1, %got_disp(x)($1)
2031; MIPS64-NEXT:  .LBB7_1: # %entry
2032; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
2033; MIPS64-NEXT:    ll $2, 0($1)
2034; MIPS64-NEXT:    bne $2, $4, .LBB7_3
2035; MIPS64-NEXT:    nop
2036; MIPS64-NEXT:  # %bb.2: # %entry
2037; MIPS64-NEXT:    # in Loop: Header=BB7_1 Depth=1
2038; MIPS64-NEXT:    move $3, $5
2039; MIPS64-NEXT:    sc $3, 0($1)
2040; MIPS64-NEXT:    beqz $3, .LBB7_1
2041; MIPS64-NEXT:    nop
2042; MIPS64-NEXT:  .LBB7_3: # %entry
2043; MIPS64-NEXT:    jr $ra
2044; MIPS64-NEXT:    daddiu $sp, $sp, 16
2045;
2046; MIPS64R2-LABEL: AtomicCmpSwap32:
2047; MIPS64R2:       # %bb.0: # %entry
2048; MIPS64R2-NEXT:    daddiu $sp, $sp, -16
2049; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap32)))
2050; MIPS64R2-NEXT:    daddu $1, $1, $25
2051; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap32)))
2052; MIPS64R2-NEXT:    sw $5, 12($sp)
2053; MIPS64R2-NEXT:    ld $1, %got_disp(x)($1)
2054; MIPS64R2-NEXT:  .LBB7_1: # %entry
2055; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
2056; MIPS64R2-NEXT:    ll $2, 0($1)
2057; MIPS64R2-NEXT:    bne $2, $4, .LBB7_3
2058; MIPS64R2-NEXT:    nop
2059; MIPS64R2-NEXT:  # %bb.2: # %entry
2060; MIPS64R2-NEXT:    # in Loop: Header=BB7_1 Depth=1
2061; MIPS64R2-NEXT:    move $3, $5
2062; MIPS64R2-NEXT:    sc $3, 0($1)
2063; MIPS64R2-NEXT:    beqz $3, .LBB7_1
2064; MIPS64R2-NEXT:    nop
2065; MIPS64R2-NEXT:  .LBB7_3: # %entry
2066; MIPS64R2-NEXT:    jr $ra
2067; MIPS64R2-NEXT:    daddiu $sp, $sp, 16
2068;
2069; MIPS64R6-LABEL: AtomicCmpSwap32:
2070; MIPS64R6:       # %bb.0: # %entry
2071; MIPS64R6-NEXT:    daddiu $sp, $sp, -16
2072; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap32)))
2073; MIPS64R6-NEXT:    daddu $1, $1, $25
2074; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap32)))
2075; MIPS64R6-NEXT:    sw $5, 12($sp)
2076; MIPS64R6-NEXT:    ld $1, %got_disp(x)($1)
2077; MIPS64R6-NEXT:  .LBB7_1: # %entry
2078; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
2079; MIPS64R6-NEXT:    ll $2, 0($1)
2080; MIPS64R6-NEXT:    bnec $2, $4, .LBB7_3
2081; MIPS64R6-NEXT:  # %bb.2: # %entry
2082; MIPS64R6-NEXT:    # in Loop: Header=BB7_1 Depth=1
2083; MIPS64R6-NEXT:    move $3, $5
2084; MIPS64R6-NEXT:    sc $3, 0($1)
2085; MIPS64R6-NEXT:    beqzc $3, .LBB7_1
2086; MIPS64R6-NEXT:    nop
2087; MIPS64R6-NEXT:  .LBB7_3: # %entry
2088; MIPS64R6-NEXT:    jr $ra
2089; MIPS64R6-NEXT:    daddiu $sp, $sp, 16
2090;
2091; MIPS64R6O0-LABEL: AtomicCmpSwap32:
2092; MIPS64R6O0:       # %bb.0: # %entry
2093; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -16
2094; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap32)))
2095; MIPS64R6O0-NEXT:    daddu $1, $1, $25
2096; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap32)))
2097; MIPS64R6O0-NEXT:    # kill: def $a0 killed $a0 killed $a0_64
2098; MIPS64R6O0-NEXT:    move $2, $5
2099; MIPS64R6O0-NEXT:    sw $2, 12($sp)
2100; MIPS64R6O0-NEXT:    lw $5, 12($sp)
2101; MIPS64R6O0-NEXT:    ld $3, %got_disp(x)($1)
2102; MIPS64R6O0-NEXT:  .LBB7_1: # %entry
2103; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
2104; MIPS64R6O0-NEXT:    ll $2, 0($3)
2105; MIPS64R6O0-NEXT:    bnec $2, $4, .LBB7_3
2106; MIPS64R6O0-NEXT:  # %bb.2: # %entry
2107; MIPS64R6O0-NEXT:    # in Loop: Header=BB7_1 Depth=1
2108; MIPS64R6O0-NEXT:    move $1, $5
2109; MIPS64R6O0-NEXT:    sc $1, 0($3)
2110; MIPS64R6O0-NEXT:    beqzc $1, .LBB7_1
2111; MIPS64R6O0-NEXT:  .LBB7_3: # %entry
2112; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 16
2113; MIPS64R6O0-NEXT:    jrc $ra
2114;
2115; MM32-LABEL: AtomicCmpSwap32:
2116; MM32:       # %bb.0: # %entry
2117; MM32-NEXT:    lui $2, %hi(_gp_disp)
2118; MM32-NEXT:    addiu $2, $2, %lo(_gp_disp)
2119; MM32-NEXT:    addiu $sp, $sp, -8
2120; MM32-NEXT:    addu $2, $2, $25
2121; MM32-NEXT:    sw $5, 4($sp)
2122; MM32-NEXT:    lw $1, %got(x)($2)
2123; MM32-NEXT:  $BB7_1: # %entry
2124; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
2125; MM32-NEXT:    ll $2, 0($1)
2126; MM32-NEXT:    bne $2, $4, $BB7_3
2127; MM32-NEXT:    nop
2128; MM32-NEXT:  # %bb.2: # %entry
2129; MM32-NEXT:    # in Loop: Header=BB7_1 Depth=1
2130; MM32-NEXT:    move $3, $5
2131; MM32-NEXT:    sc $3, 0($1)
2132; MM32-NEXT:    beqzc $3, $BB7_1
2133; MM32-NEXT:  $BB7_3: # %entry
2134; MM32-NEXT:    addiusp 8
2135; MM32-NEXT:    jrc $ra
2136;
2137; O1-LABEL: AtomicCmpSwap32:
2138; O1:       # %bb.0: # %entry
2139; O1-NEXT:    lui $2, %hi(_gp_disp)
2140; O1-NEXT:    addiu $2, $2, %lo(_gp_disp)
2141; O1-NEXT:    addiu $sp, $sp, -8
2142; O1-NEXT:    addu $1, $2, $25
2143; O1-NEXT:    sw $5, 4($sp)
2144; O1-NEXT:    lw $1, %got(x)($1)
2145; O1-NEXT:  $BB7_1: # %entry
2146; O1-NEXT:    # =>This Inner Loop Header: Depth=1
2147; O1-NEXT:    ll $2, 0($1)
2148; O1-NEXT:    bne $2, $4, $BB7_3
2149; O1-NEXT:    nop
2150; O1-NEXT:  # %bb.2: # %entry
2151; O1-NEXT:    # in Loop: Header=BB7_1 Depth=1
2152; O1-NEXT:    move $3, $5
2153; O1-NEXT:    sc $3, 0($1)
2154; O1-NEXT:    beqz $3, $BB7_1
2155; O1-NEXT:    nop
2156; O1-NEXT:  $BB7_3: # %entry
2157; O1-NEXT:    jr $ra
2158; O1-NEXT:    addiu $sp, $sp, 8
2159;
2160; O2-LABEL: AtomicCmpSwap32:
2161; O2:       # %bb.0: # %entry
2162; O2-NEXT:    lui $2, %hi(_gp_disp)
2163; O2-NEXT:    addiu $2, $2, %lo(_gp_disp)
2164; O2-NEXT:    addiu $sp, $sp, -8
2165; O2-NEXT:    addu $1, $2, $25
2166; O2-NEXT:    sw $5, 4($sp)
2167; O2-NEXT:    lw $1, %got(x)($1)
2168; O2-NEXT:  $BB7_1: # %entry
2169; O2-NEXT:    # =>This Inner Loop Header: Depth=1
2170; O2-NEXT:    ll $2, 0($1)
2171; O2-NEXT:    bne $2, $4, $BB7_3
2172; O2-NEXT:    nop
2173; O2-NEXT:  # %bb.2: # %entry
2174; O2-NEXT:    # in Loop: Header=BB7_1 Depth=1
2175; O2-NEXT:    move $3, $5
2176; O2-NEXT:    sc $3, 0($1)
2177; O2-NEXT:    beqz $3, $BB7_1
2178; O2-NEXT:    nop
2179; O2-NEXT:  $BB7_3: # %entry
2180; O2-NEXT:    jr $ra
2181; O2-NEXT:    addiu $sp, $sp, 8
2182;
2183; O3-LABEL: AtomicCmpSwap32:
2184; O3:       # %bb.0: # %entry
2185; O3-NEXT:    lui $2, %hi(_gp_disp)
2186; O3-NEXT:    addiu $2, $2, %lo(_gp_disp)
2187; O3-NEXT:    addiu $sp, $sp, -8
2188; O3-NEXT:    addu $1, $2, $25
2189; O3-NEXT:    sw $5, 4($sp)
2190; O3-NEXT:    lw $1, %got(x)($1)
2191; O3-NEXT:  $BB7_1: # %entry
2192; O3-NEXT:    # =>This Inner Loop Header: Depth=1
2193; O3-NEXT:    ll $2, 0($1)
2194; O3-NEXT:    bne $2, $4, $BB7_3
2195; O3-NEXT:    nop
2196; O3-NEXT:  # %bb.2: # %entry
2197; O3-NEXT:    # in Loop: Header=BB7_1 Depth=1
2198; O3-NEXT:    move $3, $5
2199; O3-NEXT:    sc $3, 0($1)
2200; O3-NEXT:    beqz $3, $BB7_1
2201; O3-NEXT:    nop
2202; O3-NEXT:  $BB7_3: # %entry
2203; O3-NEXT:    jr $ra
2204; O3-NEXT:    addiu $sp, $sp, 8
2205;
2206; MIPS32EB-LABEL: AtomicCmpSwap32:
2207; MIPS32EB:       # %bb.0: # %entry
2208; MIPS32EB-NEXT:    lui $2, %hi(_gp_disp)
2209; MIPS32EB-NEXT:    addiu $2, $2, %lo(_gp_disp)
2210; MIPS32EB-NEXT:    addiu $sp, $sp, -8
2211; MIPS32EB-NEXT:    addu $1, $2, $25
2212; MIPS32EB-NEXT:    sw $5, 4($sp)
2213; MIPS32EB-NEXT:    lw $1, %got(x)($1)
2214; MIPS32EB-NEXT:  $BB7_1: # %entry
2215; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
2216; MIPS32EB-NEXT:    ll $2, 0($1)
2217; MIPS32EB-NEXT:    bne $2, $4, $BB7_3
2218; MIPS32EB-NEXT:    nop
2219; MIPS32EB-NEXT:  # %bb.2: # %entry
2220; MIPS32EB-NEXT:    # in Loop: Header=BB7_1 Depth=1
2221; MIPS32EB-NEXT:    move $3, $5
2222; MIPS32EB-NEXT:    sc $3, 0($1)
2223; MIPS32EB-NEXT:    beqz $3, $BB7_1
2224; MIPS32EB-NEXT:    nop
2225; MIPS32EB-NEXT:  $BB7_3: # %entry
2226; MIPS32EB-NEXT:    jr $ra
2227; MIPS32EB-NEXT:    addiu $sp, $sp, 8
2228entry:
2229  %newval.addr = alloca i32, align 4
2230  store i32 %newval, i32* %newval.addr, align 4
2231  %tmp = load i32, i32* %newval.addr, align 4
2232  %0 = cmpxchg i32* @x, i32 %oldval, i32 %tmp monotonic monotonic
2233  %1 = extractvalue { i32, i1 } %0, 0
2234  ret i32 %1
2235
2236}
2237
2238@y = common global i8 0, align 1
2239
2240define signext i8 @AtomicLoadAdd8(i8 signext %incr) nounwind {
2241; MIPS32-LABEL: AtomicLoadAdd8:
2242; MIPS32:       # %bb.0: # %entry
2243; MIPS32-NEXT:    lui $2, %hi(_gp_disp)
2244; MIPS32-NEXT:    addiu $2, $2, %lo(_gp_disp)
2245; MIPS32-NEXT:    addu $1, $2, $25
2246; MIPS32-NEXT:    lw $1, %got(y)($1)
2247; MIPS32-NEXT:    addiu $2, $zero, -4
2248; MIPS32-NEXT:    and $2, $1, $2
2249; MIPS32-NEXT:    andi $1, $1, 3
2250; MIPS32-NEXT:    sll $3, $1, 3
2251; MIPS32-NEXT:    ori $1, $zero, 255
2252; MIPS32-NEXT:    sllv $5, $1, $3
2253; MIPS32-NEXT:    nor $6, $zero, $5
2254; MIPS32-NEXT:    sllv $4, $4, $3
2255; MIPS32-NEXT:  $BB8_1: # %entry
2256; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
2257; MIPS32-NEXT:    ll $7, 0($2)
2258; MIPS32-NEXT:    addu $8, $7, $4
2259; MIPS32-NEXT:    and $8, $8, $5
2260; MIPS32-NEXT:    and $9, $7, $6
2261; MIPS32-NEXT:    or $9, $9, $8
2262; MIPS32-NEXT:    sc $9, 0($2)
2263; MIPS32-NEXT:    beqz $9, $BB8_1
2264; MIPS32-NEXT:    nop
2265; MIPS32-NEXT:  # %bb.2: # %entry
2266; MIPS32-NEXT:    and $1, $7, $5
2267; MIPS32-NEXT:    srlv $1, $1, $3
2268; MIPS32-NEXT:    sll $1, $1, 24
2269; MIPS32-NEXT:    sra $1, $1, 24
2270; MIPS32-NEXT:  # %bb.3: # %entry
2271; MIPS32-NEXT:    sll $1, $1, 24
2272; MIPS32-NEXT:    jr $ra
2273; MIPS32-NEXT:    sra $2, $1, 24
2274;
2275; MIPS32O0-LABEL: AtomicLoadAdd8:
2276; MIPS32O0:       # %bb.0: # %entry
2277; MIPS32O0-NEXT:    lui $2, %hi(_gp_disp)
2278; MIPS32O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
2279; MIPS32O0-NEXT:    addiu $sp, $sp, -8
2280; MIPS32O0-NEXT:    addu $1, $2, $25
2281; MIPS32O0-NEXT:    lw $1, %got(y)($1)
2282; MIPS32O0-NEXT:    addiu $2, $zero, -4
2283; MIPS32O0-NEXT:    and $5, $1, $2
2284; MIPS32O0-NEXT:    andi $1, $1, 3
2285; MIPS32O0-NEXT:    sll $9, $1, 3
2286; MIPS32O0-NEXT:    ori $1, $zero, 255
2287; MIPS32O0-NEXT:    sllv $7, $1, $9
2288; MIPS32O0-NEXT:    nor $8, $zero, $7
2289; MIPS32O0-NEXT:    sllv $6, $4, $9
2290; MIPS32O0-NEXT:  $BB8_1: # %entry
2291; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
2292; MIPS32O0-NEXT:    ll $2, 0($5)
2293; MIPS32O0-NEXT:    addu $3, $2, $6
2294; MIPS32O0-NEXT:    and $3, $3, $7
2295; MIPS32O0-NEXT:    and $4, $2, $8
2296; MIPS32O0-NEXT:    or $4, $4, $3
2297; MIPS32O0-NEXT:    sc $4, 0($5)
2298; MIPS32O0-NEXT:    beqz $4, $BB8_1
2299; MIPS32O0-NEXT:    nop
2300; MIPS32O0-NEXT:  # %bb.2: # %entry
2301; MIPS32O0-NEXT:    and $1, $2, $7
2302; MIPS32O0-NEXT:    srlv $1, $1, $9
2303; MIPS32O0-NEXT:    sll $1, $1, 24
2304; MIPS32O0-NEXT:    sra $1, $1, 24
2305; MIPS32O0-NEXT:  # %bb.3: # %entry
2306; MIPS32O0-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2307; MIPS32O0-NEXT:  # %bb.4: # %entry
2308; MIPS32O0-NEXT:    lw $1, 4($sp) # 4-byte Folded Reload
2309; MIPS32O0-NEXT:    sll $1, $1, 24
2310; MIPS32O0-NEXT:    sra $2, $1, 24
2311; MIPS32O0-NEXT:    addiu $sp, $sp, 8
2312; MIPS32O0-NEXT:    jr $ra
2313; MIPS32O0-NEXT:    nop
2314;
2315; MIPS32R2-LABEL: AtomicLoadAdd8:
2316; MIPS32R2:       # %bb.0: # %entry
2317; MIPS32R2-NEXT:    lui $2, %hi(_gp_disp)
2318; MIPS32R2-NEXT:    addiu $2, $2, %lo(_gp_disp)
2319; MIPS32R2-NEXT:    addu $1, $2, $25
2320; MIPS32R2-NEXT:    lw $1, %got(y)($1)
2321; MIPS32R2-NEXT:    addiu $2, $zero, -4
2322; MIPS32R2-NEXT:    and $2, $1, $2
2323; MIPS32R2-NEXT:    andi $1, $1, 3
2324; MIPS32R2-NEXT:    sll $3, $1, 3
2325; MIPS32R2-NEXT:    ori $1, $zero, 255
2326; MIPS32R2-NEXT:    sllv $5, $1, $3
2327; MIPS32R2-NEXT:    nor $6, $zero, $5
2328; MIPS32R2-NEXT:    sllv $4, $4, $3
2329; MIPS32R2-NEXT:  $BB8_1: # %entry
2330; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
2331; MIPS32R2-NEXT:    ll $7, 0($2)
2332; MIPS32R2-NEXT:    addu $8, $7, $4
2333; MIPS32R2-NEXT:    and $8, $8, $5
2334; MIPS32R2-NEXT:    and $9, $7, $6
2335; MIPS32R2-NEXT:    or $9, $9, $8
2336; MIPS32R2-NEXT:    sc $9, 0($2)
2337; MIPS32R2-NEXT:    beqz $9, $BB8_1
2338; MIPS32R2-NEXT:    nop
2339; MIPS32R2-NEXT:  # %bb.2: # %entry
2340; MIPS32R2-NEXT:    and $1, $7, $5
2341; MIPS32R2-NEXT:    srlv $1, $1, $3
2342; MIPS32R2-NEXT:    seb $1, $1
2343; MIPS32R2-NEXT:  # %bb.3: # %entry
2344; MIPS32R2-NEXT:    jr $ra
2345; MIPS32R2-NEXT:    seb $2, $1
2346;
2347; MIPS32R6-LABEL: AtomicLoadAdd8:
2348; MIPS32R6:       # %bb.0: # %entry
2349; MIPS32R6-NEXT:    lui $2, %hi(_gp_disp)
2350; MIPS32R6-NEXT:    addiu $2, $2, %lo(_gp_disp)
2351; MIPS32R6-NEXT:    addu $1, $2, $25
2352; MIPS32R6-NEXT:    lw $1, %got(y)($1)
2353; MIPS32R6-NEXT:    addiu $2, $zero, -4
2354; MIPS32R6-NEXT:    and $2, $1, $2
2355; MIPS32R6-NEXT:    andi $1, $1, 3
2356; MIPS32R6-NEXT:    sll $3, $1, 3
2357; MIPS32R6-NEXT:    ori $1, $zero, 255
2358; MIPS32R6-NEXT:    sllv $5, $1, $3
2359; MIPS32R6-NEXT:    nor $6, $zero, $5
2360; MIPS32R6-NEXT:    sllv $4, $4, $3
2361; MIPS32R6-NEXT:  $BB8_1: # %entry
2362; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
2363; MIPS32R6-NEXT:    ll $7, 0($2)
2364; MIPS32R6-NEXT:    addu $8, $7, $4
2365; MIPS32R6-NEXT:    and $8, $8, $5
2366; MIPS32R6-NEXT:    and $9, $7, $6
2367; MIPS32R6-NEXT:    or $9, $9, $8
2368; MIPS32R6-NEXT:    sc $9, 0($2)
2369; MIPS32R6-NEXT:    beqzc $9, $BB8_1
2370; MIPS32R6-NEXT:  # %bb.2: # %entry
2371; MIPS32R6-NEXT:    and $1, $7, $5
2372; MIPS32R6-NEXT:    srlv $1, $1, $3
2373; MIPS32R6-NEXT:    seb $1, $1
2374; MIPS32R6-NEXT:  # %bb.3: # %entry
2375; MIPS32R6-NEXT:    jr $ra
2376; MIPS32R6-NEXT:    seb $2, $1
2377;
2378; MIPS32R6O0-LABEL: AtomicLoadAdd8:
2379; MIPS32R6O0:       # %bb.0: # %entry
2380; MIPS32R6O0-NEXT:    lui $2, %hi(_gp_disp)
2381; MIPS32R6O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
2382; MIPS32R6O0-NEXT:    addiu $sp, $sp, -8
2383; MIPS32R6O0-NEXT:    addu $1, $2, $25
2384; MIPS32R6O0-NEXT:    # kill: def $v0 killed $a0
2385; MIPS32R6O0-NEXT:    lw $1, %got(y)($1)
2386; MIPS32R6O0-NEXT:    addiu $2, $zero, -4
2387; MIPS32R6O0-NEXT:    and $5, $1, $2
2388; MIPS32R6O0-NEXT:    andi $1, $1, 3
2389; MIPS32R6O0-NEXT:    sll $9, $1, 3
2390; MIPS32R6O0-NEXT:    ori $1, $zero, 255
2391; MIPS32R6O0-NEXT:    sllv $7, $1, $9
2392; MIPS32R6O0-NEXT:    nor $8, $zero, $7
2393; MIPS32R6O0-NEXT:    sllv $6, $4, $9
2394; MIPS32R6O0-NEXT:  $BB8_1: # %entry
2395; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
2396; MIPS32R6O0-NEXT:    ll $2, 0($5)
2397; MIPS32R6O0-NEXT:    addu $3, $2, $6
2398; MIPS32R6O0-NEXT:    and $3, $3, $7
2399; MIPS32R6O0-NEXT:    and $4, $2, $8
2400; MIPS32R6O0-NEXT:    or $4, $4, $3
2401; MIPS32R6O0-NEXT:    sc $4, 0($5)
2402; MIPS32R6O0-NEXT:    beqzc $4, $BB8_1
2403; MIPS32R6O0-NEXT:  # %bb.2: # %entry
2404; MIPS32R6O0-NEXT:    and $1, $2, $7
2405; MIPS32R6O0-NEXT:    srlv $1, $1, $9
2406; MIPS32R6O0-NEXT:    seb $1, $1
2407; MIPS32R6O0-NEXT:  # %bb.3: # %entry
2408; MIPS32R6O0-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2409; MIPS32R6O0-NEXT:  # %bb.4: # %entry
2410; MIPS32R6O0-NEXT:    lw $1, 4($sp) # 4-byte Folded Reload
2411; MIPS32R6O0-NEXT:    seb $2, $1
2412; MIPS32R6O0-NEXT:    addiu $sp, $sp, 8
2413; MIPS32R6O0-NEXT:    jrc $ra
2414;
2415; MIPS4-LABEL: AtomicLoadAdd8:
2416; MIPS4:       # %bb.0: # %entry
2417; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd8)))
2418; MIPS4-NEXT:    daddu $1, $1, $25
2419; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd8)))
2420; MIPS4-NEXT:    ld $1, %got_disp(y)($1)
2421; MIPS4-NEXT:    daddiu $2, $zero, -4
2422; MIPS4-NEXT:    and $2, $1, $2
2423; MIPS4-NEXT:    andi $1, $1, 3
2424; MIPS4-NEXT:    sll $3, $1, 3
2425; MIPS4-NEXT:    ori $1, $zero, 255
2426; MIPS4-NEXT:    sllv $5, $1, $3
2427; MIPS4-NEXT:    nor $6, $zero, $5
2428; MIPS4-NEXT:    sllv $4, $4, $3
2429; MIPS4-NEXT:  .LBB8_1: # %entry
2430; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
2431; MIPS4-NEXT:    ll $7, 0($2)
2432; MIPS4-NEXT:    addu $8, $7, $4
2433; MIPS4-NEXT:    and $8, $8, $5
2434; MIPS4-NEXT:    and $9, $7, $6
2435; MIPS4-NEXT:    or $9, $9, $8
2436; MIPS4-NEXT:    sc $9, 0($2)
2437; MIPS4-NEXT:    beqz $9, .LBB8_1
2438; MIPS4-NEXT:    nop
2439; MIPS4-NEXT:  # %bb.2: # %entry
2440; MIPS4-NEXT:    and $1, $7, $5
2441; MIPS4-NEXT:    srlv $1, $1, $3
2442; MIPS4-NEXT:    sll $1, $1, 24
2443; MIPS4-NEXT:    sra $1, $1, 24
2444; MIPS4-NEXT:  # %bb.3: # %entry
2445; MIPS4-NEXT:    sll $1, $1, 24
2446; MIPS4-NEXT:    jr $ra
2447; MIPS4-NEXT:    sra $2, $1, 24
2448;
2449; MIPS64-LABEL: AtomicLoadAdd8:
2450; MIPS64:       # %bb.0: # %entry
2451; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd8)))
2452; MIPS64-NEXT:    daddu $1, $1, $25
2453; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd8)))
2454; MIPS64-NEXT:    ld $1, %got_disp(y)($1)
2455; MIPS64-NEXT:    daddiu $2, $zero, -4
2456; MIPS64-NEXT:    and $2, $1, $2
2457; MIPS64-NEXT:    andi $1, $1, 3
2458; MIPS64-NEXT:    sll $3, $1, 3
2459; MIPS64-NEXT:    ori $1, $zero, 255
2460; MIPS64-NEXT:    sllv $5, $1, $3
2461; MIPS64-NEXT:    nor $6, $zero, $5
2462; MIPS64-NEXT:    sllv $4, $4, $3
2463; MIPS64-NEXT:  .LBB8_1: # %entry
2464; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
2465; MIPS64-NEXT:    ll $7, 0($2)
2466; MIPS64-NEXT:    addu $8, $7, $4
2467; MIPS64-NEXT:    and $8, $8, $5
2468; MIPS64-NEXT:    and $9, $7, $6
2469; MIPS64-NEXT:    or $9, $9, $8
2470; MIPS64-NEXT:    sc $9, 0($2)
2471; MIPS64-NEXT:    beqz $9, .LBB8_1
2472; MIPS64-NEXT:    nop
2473; MIPS64-NEXT:  # %bb.2: # %entry
2474; MIPS64-NEXT:    and $1, $7, $5
2475; MIPS64-NEXT:    srlv $1, $1, $3
2476; MIPS64-NEXT:    sll $1, $1, 24
2477; MIPS64-NEXT:    sra $1, $1, 24
2478; MIPS64-NEXT:  # %bb.3: # %entry
2479; MIPS64-NEXT:    sll $1, $1, 24
2480; MIPS64-NEXT:    jr $ra
2481; MIPS64-NEXT:    sra $2, $1, 24
2482;
2483; MIPS64R2-LABEL: AtomicLoadAdd8:
2484; MIPS64R2:       # %bb.0: # %entry
2485; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd8)))
2486; MIPS64R2-NEXT:    daddu $1, $1, $25
2487; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd8)))
2488; MIPS64R2-NEXT:    ld $1, %got_disp(y)($1)
2489; MIPS64R2-NEXT:    daddiu $2, $zero, -4
2490; MIPS64R2-NEXT:    and $2, $1, $2
2491; MIPS64R2-NEXT:    andi $1, $1, 3
2492; MIPS64R2-NEXT:    sll $3, $1, 3
2493; MIPS64R2-NEXT:    ori $1, $zero, 255
2494; MIPS64R2-NEXT:    sllv $5, $1, $3
2495; MIPS64R2-NEXT:    nor $6, $zero, $5
2496; MIPS64R2-NEXT:    sllv $4, $4, $3
2497; MIPS64R2-NEXT:  .LBB8_1: # %entry
2498; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
2499; MIPS64R2-NEXT:    ll $7, 0($2)
2500; MIPS64R2-NEXT:    addu $8, $7, $4
2501; MIPS64R2-NEXT:    and $8, $8, $5
2502; MIPS64R2-NEXT:    and $9, $7, $6
2503; MIPS64R2-NEXT:    or $9, $9, $8
2504; MIPS64R2-NEXT:    sc $9, 0($2)
2505; MIPS64R2-NEXT:    beqz $9, .LBB8_1
2506; MIPS64R2-NEXT:    nop
2507; MIPS64R2-NEXT:  # %bb.2: # %entry
2508; MIPS64R2-NEXT:    and $1, $7, $5
2509; MIPS64R2-NEXT:    srlv $1, $1, $3
2510; MIPS64R2-NEXT:    seb $1, $1
2511; MIPS64R2-NEXT:  # %bb.3: # %entry
2512; MIPS64R2-NEXT:    jr $ra
2513; MIPS64R2-NEXT:    seb $2, $1
2514;
2515; MIPS64R6-LABEL: AtomicLoadAdd8:
2516; MIPS64R6:       # %bb.0: # %entry
2517; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd8)))
2518; MIPS64R6-NEXT:    daddu $1, $1, $25
2519; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd8)))
2520; MIPS64R6-NEXT:    ld $1, %got_disp(y)($1)
2521; MIPS64R6-NEXT:    daddiu $2, $zero, -4
2522; MIPS64R6-NEXT:    and $2, $1, $2
2523; MIPS64R6-NEXT:    andi $1, $1, 3
2524; MIPS64R6-NEXT:    sll $3, $1, 3
2525; MIPS64R6-NEXT:    ori $1, $zero, 255
2526; MIPS64R6-NEXT:    sllv $5, $1, $3
2527; MIPS64R6-NEXT:    nor $6, $zero, $5
2528; MIPS64R6-NEXT:    sllv $4, $4, $3
2529; MIPS64R6-NEXT:  .LBB8_1: # %entry
2530; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
2531; MIPS64R6-NEXT:    ll $7, 0($2)
2532; MIPS64R6-NEXT:    addu $8, $7, $4
2533; MIPS64R6-NEXT:    and $8, $8, $5
2534; MIPS64R6-NEXT:    and $9, $7, $6
2535; MIPS64R6-NEXT:    or $9, $9, $8
2536; MIPS64R6-NEXT:    sc $9, 0($2)
2537; MIPS64R6-NEXT:    beqzc $9, .LBB8_1
2538; MIPS64R6-NEXT:  # %bb.2: # %entry
2539; MIPS64R6-NEXT:    and $1, $7, $5
2540; MIPS64R6-NEXT:    srlv $1, $1, $3
2541; MIPS64R6-NEXT:    seb $1, $1
2542; MIPS64R6-NEXT:  # %bb.3: # %entry
2543; MIPS64R6-NEXT:    jr $ra
2544; MIPS64R6-NEXT:    seb $2, $1
2545;
2546; MIPS64R6O0-LABEL: AtomicLoadAdd8:
2547; MIPS64R6O0:       # %bb.0: # %entry
2548; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -16
2549; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd8)))
2550; MIPS64R6O0-NEXT:    daddu $1, $1, $25
2551; MIPS64R6O0-NEXT:    daddiu $2, $1, %lo(%neg(%gp_rel(AtomicLoadAdd8)))
2552; MIPS64R6O0-NEXT:    move $1, $4
2553; MIPS64R6O0-NEXT:    ld $2, %got_disp(y)($2)
2554; MIPS64R6O0-NEXT:    daddiu $3, $zero, -4
2555; MIPS64R6O0-NEXT:    and $5, $2, $3
2556; MIPS64R6O0-NEXT:    andi $2, $2, 3
2557; MIPS64R6O0-NEXT:    xori $2, $2, 3
2558; MIPS64R6O0-NEXT:    sll $9, $2, 3
2559; MIPS64R6O0-NEXT:    ori $2, $zero, 255
2560; MIPS64R6O0-NEXT:    sllv $7, $2, $9
2561; MIPS64R6O0-NEXT:    nor $8, $zero, $7
2562; MIPS64R6O0-NEXT:    sllv $6, $1, $9
2563; MIPS64R6O0-NEXT:  .LBB8_1: # %entry
2564; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
2565; MIPS64R6O0-NEXT:    ll $2, 0($5)
2566; MIPS64R6O0-NEXT:    addu $3, $2, $6
2567; MIPS64R6O0-NEXT:    and $3, $3, $7
2568; MIPS64R6O0-NEXT:    and $4, $2, $8
2569; MIPS64R6O0-NEXT:    or $4, $4, $3
2570; MIPS64R6O0-NEXT:    sc $4, 0($5)
2571; MIPS64R6O0-NEXT:    beqzc $4, .LBB8_1
2572; MIPS64R6O0-NEXT:  # %bb.2: # %entry
2573; MIPS64R6O0-NEXT:    and $1, $2, $7
2574; MIPS64R6O0-NEXT:    srlv $1, $1, $9
2575; MIPS64R6O0-NEXT:    seb $1, $1
2576; MIPS64R6O0-NEXT:  # %bb.3: # %entry
2577; MIPS64R6O0-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
2578; MIPS64R6O0-NEXT:  # %bb.4: # %entry
2579; MIPS64R6O0-NEXT:    lw $1, 12($sp) # 4-byte Folded Reload
2580; MIPS64R6O0-NEXT:    seb $2, $1
2581; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 16
2582; MIPS64R6O0-NEXT:    jrc $ra
2583;
2584; MM32-LABEL: AtomicLoadAdd8:
2585; MM32:       # %bb.0: # %entry
2586; MM32-NEXT:    lui $2, %hi(_gp_disp)
2587; MM32-NEXT:    addiu $2, $2, %lo(_gp_disp)
2588; MM32-NEXT:    addu $2, $2, $25
2589; MM32-NEXT:    lw $1, %got(y)($2)
2590; MM32-NEXT:    addiu $2, $zero, -4
2591; MM32-NEXT:    and $2, $1, $2
2592; MM32-NEXT:    andi $1, $1, 3
2593; MM32-NEXT:    sll $3, $1, 3
2594; MM32-NEXT:    ori $1, $zero, 255
2595; MM32-NEXT:    sllv $5, $1, $3
2596; MM32-NEXT:    nor $6, $zero, $5
2597; MM32-NEXT:    sllv $4, $4, $3
2598; MM32-NEXT:  $BB8_1: # %entry
2599; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
2600; MM32-NEXT:    ll $7, 0($2)
2601; MM32-NEXT:    addu $8, $7, $4
2602; MM32-NEXT:    and $8, $8, $5
2603; MM32-NEXT:    and $9, $7, $6
2604; MM32-NEXT:    or $9, $9, $8
2605; MM32-NEXT:    sc $9, 0($2)
2606; MM32-NEXT:    beqzc $9, $BB8_1
2607; MM32-NEXT:  # %bb.2: # %entry
2608; MM32-NEXT:    and $1, $7, $5
2609; MM32-NEXT:    srlv $1, $1, $3
2610; MM32-NEXT:    seb $1, $1
2611; MM32-NEXT:  # %bb.3: # %entry
2612; MM32-NEXT:    jr $ra
2613; MM32-NEXT:    seb $2, $1
2614;
2615; O1-LABEL: AtomicLoadAdd8:
2616; O1:       # %bb.0: # %entry
2617; O1-NEXT:    lui $2, %hi(_gp_disp)
2618; O1-NEXT:    addiu $2, $2, %lo(_gp_disp)
2619; O1-NEXT:    addu $1, $2, $25
2620; O1-NEXT:    lw $1, %got(y)($1)
2621; O1-NEXT:    addiu $2, $zero, -4
2622; O1-NEXT:    and $2, $1, $2
2623; O1-NEXT:    andi $1, $1, 3
2624; O1-NEXT:    sll $3, $1, 3
2625; O1-NEXT:    ori $1, $zero, 255
2626; O1-NEXT:    sllv $5, $1, $3
2627; O1-NEXT:    nor $6, $zero, $5
2628; O1-NEXT:    sllv $4, $4, $3
2629; O1-NEXT:  $BB8_1: # %entry
2630; O1-NEXT:    # =>This Inner Loop Header: Depth=1
2631; O1-NEXT:    ll $7, 0($2)
2632; O1-NEXT:    addu $8, $7, $4
2633; O1-NEXT:    and $8, $8, $5
2634; O1-NEXT:    and $9, $7, $6
2635; O1-NEXT:    or $9, $9, $8
2636; O1-NEXT:    sc $9, 0($2)
2637; O1-NEXT:    beqz $9, $BB8_1
2638; O1-NEXT:    nop
2639; O1-NEXT:  # %bb.2: # %entry
2640; O1-NEXT:    and $1, $7, $5
2641; O1-NEXT:    srlv $1, $1, $3
2642; O1-NEXT:    sll $1, $1, 24
2643; O1-NEXT:    sra $1, $1, 24
2644; O1-NEXT:  # %bb.3: # %entry
2645; O1-NEXT:    sll $1, $1, 24
2646; O1-NEXT:    jr $ra
2647; O1-NEXT:    sra $2, $1, 24
2648;
2649; O2-LABEL: AtomicLoadAdd8:
2650; O2:       # %bb.0: # %entry
2651; O2-NEXT:    lui $2, %hi(_gp_disp)
2652; O2-NEXT:    addiu $2, $2, %lo(_gp_disp)
2653; O2-NEXT:    addu $1, $2, $25
2654; O2-NEXT:    lw $1, %got(y)($1)
2655; O2-NEXT:    addiu $2, $zero, -4
2656; O2-NEXT:    and $2, $1, $2
2657; O2-NEXT:    andi $1, $1, 3
2658; O2-NEXT:    sll $3, $1, 3
2659; O2-NEXT:    ori $1, $zero, 255
2660; O2-NEXT:    sllv $5, $1, $3
2661; O2-NEXT:    nor $6, $zero, $5
2662; O2-NEXT:    sllv $4, $4, $3
2663; O2-NEXT:  $BB8_1: # %entry
2664; O2-NEXT:    # =>This Inner Loop Header: Depth=1
2665; O2-NEXT:    ll $7, 0($2)
2666; O2-NEXT:    addu $8, $7, $4
2667; O2-NEXT:    and $8, $8, $5
2668; O2-NEXT:    and $9, $7, $6
2669; O2-NEXT:    or $9, $9, $8
2670; O2-NEXT:    sc $9, 0($2)
2671; O2-NEXT:    beqz $9, $BB8_1
2672; O2-NEXT:    nop
2673; O2-NEXT:  # %bb.2: # %entry
2674; O2-NEXT:    and $1, $7, $5
2675; O2-NEXT:    srlv $1, $1, $3
2676; O2-NEXT:    sll $1, $1, 24
2677; O2-NEXT:    sra $1, $1, 24
2678; O2-NEXT:  # %bb.3: # %entry
2679; O2-NEXT:    sll $1, $1, 24
2680; O2-NEXT:    jr $ra
2681; O2-NEXT:    sra $2, $1, 24
2682;
2683; O3-LABEL: AtomicLoadAdd8:
2684; O3:       # %bb.0: # %entry
2685; O3-NEXT:    lui $2, %hi(_gp_disp)
2686; O3-NEXT:    addiu $2, $2, %lo(_gp_disp)
2687; O3-NEXT:    addu $1, $2, $25
2688; O3-NEXT:    addiu $2, $zero, -4
2689; O3-NEXT:    lw $1, %got(y)($1)
2690; O3-NEXT:    and $2, $1, $2
2691; O3-NEXT:    andi $1, $1, 3
2692; O3-NEXT:    sll $3, $1, 3
2693; O3-NEXT:    ori $1, $zero, 255
2694; O3-NEXT:    sllv $5, $1, $3
2695; O3-NEXT:    sllv $4, $4, $3
2696; O3-NEXT:    nor $6, $zero, $5
2697; O3-NEXT:  $BB8_1: # %entry
2698; O3-NEXT:    # =>This Inner Loop Header: Depth=1
2699; O3-NEXT:    ll $7, 0($2)
2700; O3-NEXT:    addu $8, $7, $4
2701; O3-NEXT:    and $8, $8, $5
2702; O3-NEXT:    and $9, $7, $6
2703; O3-NEXT:    or $9, $9, $8
2704; O3-NEXT:    sc $9, 0($2)
2705; O3-NEXT:    beqz $9, $BB8_1
2706; O3-NEXT:    nop
2707; O3-NEXT:  # %bb.2: # %entry
2708; O3-NEXT:    and $1, $7, $5
2709; O3-NEXT:    srlv $1, $1, $3
2710; O3-NEXT:    sll $1, $1, 24
2711; O3-NEXT:    sra $1, $1, 24
2712; O3-NEXT:  # %bb.3: # %entry
2713; O3-NEXT:    sll $1, $1, 24
2714; O3-NEXT:    jr $ra
2715; O3-NEXT:    sra $2, $1, 24
2716;
2717; MIPS32EB-LABEL: AtomicLoadAdd8:
2718; MIPS32EB:       # %bb.0: # %entry
2719; MIPS32EB-NEXT:    lui $2, %hi(_gp_disp)
2720; MIPS32EB-NEXT:    addiu $2, $2, %lo(_gp_disp)
2721; MIPS32EB-NEXT:    addu $1, $2, $25
2722; MIPS32EB-NEXT:    lw $1, %got(y)($1)
2723; MIPS32EB-NEXT:    addiu $2, $zero, -4
2724; MIPS32EB-NEXT:    and $2, $1, $2
2725; MIPS32EB-NEXT:    andi $1, $1, 3
2726; MIPS32EB-NEXT:    xori $1, $1, 3
2727; MIPS32EB-NEXT:    sll $3, $1, 3
2728; MIPS32EB-NEXT:    ori $1, $zero, 255
2729; MIPS32EB-NEXT:    sllv $5, $1, $3
2730; MIPS32EB-NEXT:    nor $6, $zero, $5
2731; MIPS32EB-NEXT:    sllv $4, $4, $3
2732; MIPS32EB-NEXT:  $BB8_1: # %entry
2733; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
2734; MIPS32EB-NEXT:    ll $7, 0($2)
2735; MIPS32EB-NEXT:    addu $8, $7, $4
2736; MIPS32EB-NEXT:    and $8, $8, $5
2737; MIPS32EB-NEXT:    and $9, $7, $6
2738; MIPS32EB-NEXT:    or $9, $9, $8
2739; MIPS32EB-NEXT:    sc $9, 0($2)
2740; MIPS32EB-NEXT:    beqz $9, $BB8_1
2741; MIPS32EB-NEXT:    nop
2742; MIPS32EB-NEXT:  # %bb.2: # %entry
2743; MIPS32EB-NEXT:    and $1, $7, $5
2744; MIPS32EB-NEXT:    srlv $1, $1, $3
2745; MIPS32EB-NEXT:    sll $1, $1, 24
2746; MIPS32EB-NEXT:    sra $1, $1, 24
2747; MIPS32EB-NEXT:  # %bb.3: # %entry
2748; MIPS32EB-NEXT:    sll $1, $1, 24
2749; MIPS32EB-NEXT:    jr $ra
2750; MIPS32EB-NEXT:    sra $2, $1, 24
2751entry:
2752  %0 = atomicrmw add i8* @y, i8 %incr monotonic
2753  ret i8 %0
2754}
2755
2756define signext i8 @AtomicLoadSub8(i8 signext %incr) nounwind {
2757; MIPS32-LABEL: AtomicLoadSub8:
2758; MIPS32:       # %bb.0: # %entry
2759; MIPS32-NEXT:    lui $2, %hi(_gp_disp)
2760; MIPS32-NEXT:    addiu $2, $2, %lo(_gp_disp)
2761; MIPS32-NEXT:    addu $1, $2, $25
2762; MIPS32-NEXT:    lw $1, %got(y)($1)
2763; MIPS32-NEXT:    addiu $2, $zero, -4
2764; MIPS32-NEXT:    and $2, $1, $2
2765; MIPS32-NEXT:    andi $1, $1, 3
2766; MIPS32-NEXT:    sll $3, $1, 3
2767; MIPS32-NEXT:    ori $1, $zero, 255
2768; MIPS32-NEXT:    sllv $5, $1, $3
2769; MIPS32-NEXT:    nor $6, $zero, $5
2770; MIPS32-NEXT:    sllv $4, $4, $3
2771; MIPS32-NEXT:  $BB9_1: # %entry
2772; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
2773; MIPS32-NEXT:    ll $7, 0($2)
2774; MIPS32-NEXT:    subu $8, $7, $4
2775; MIPS32-NEXT:    and $8, $8, $5
2776; MIPS32-NEXT:    and $9, $7, $6
2777; MIPS32-NEXT:    or $9, $9, $8
2778; MIPS32-NEXT:    sc $9, 0($2)
2779; MIPS32-NEXT:    beqz $9, $BB9_1
2780; MIPS32-NEXT:    nop
2781; MIPS32-NEXT:  # %bb.2: # %entry
2782; MIPS32-NEXT:    and $1, $7, $5
2783; MIPS32-NEXT:    srlv $1, $1, $3
2784; MIPS32-NEXT:    sll $1, $1, 24
2785; MIPS32-NEXT:    sra $1, $1, 24
2786; MIPS32-NEXT:  # %bb.3: # %entry
2787; MIPS32-NEXT:    sll $1, $1, 24
2788; MIPS32-NEXT:    jr $ra
2789; MIPS32-NEXT:    sra $2, $1, 24
2790;
2791; MIPS32O0-LABEL: AtomicLoadSub8:
2792; MIPS32O0:       # %bb.0: # %entry
2793; MIPS32O0-NEXT:    lui $2, %hi(_gp_disp)
2794; MIPS32O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
2795; MIPS32O0-NEXT:    addiu $sp, $sp, -8
2796; MIPS32O0-NEXT:    addu $1, $2, $25
2797; MIPS32O0-NEXT:    lw $1, %got(y)($1)
2798; MIPS32O0-NEXT:    addiu $2, $zero, -4
2799; MIPS32O0-NEXT:    and $5, $1, $2
2800; MIPS32O0-NEXT:    andi $1, $1, 3
2801; MIPS32O0-NEXT:    sll $9, $1, 3
2802; MIPS32O0-NEXT:    ori $1, $zero, 255
2803; MIPS32O0-NEXT:    sllv $7, $1, $9
2804; MIPS32O0-NEXT:    nor $8, $zero, $7
2805; MIPS32O0-NEXT:    sllv $6, $4, $9
2806; MIPS32O0-NEXT:  $BB9_1: # %entry
2807; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
2808; MIPS32O0-NEXT:    ll $2, 0($5)
2809; MIPS32O0-NEXT:    subu $3, $2, $6
2810; MIPS32O0-NEXT:    and $3, $3, $7
2811; MIPS32O0-NEXT:    and $4, $2, $8
2812; MIPS32O0-NEXT:    or $4, $4, $3
2813; MIPS32O0-NEXT:    sc $4, 0($5)
2814; MIPS32O0-NEXT:    beqz $4, $BB9_1
2815; MIPS32O0-NEXT:    nop
2816; MIPS32O0-NEXT:  # %bb.2: # %entry
2817; MIPS32O0-NEXT:    and $1, $2, $7
2818; MIPS32O0-NEXT:    srlv $1, $1, $9
2819; MIPS32O0-NEXT:    sll $1, $1, 24
2820; MIPS32O0-NEXT:    sra $1, $1, 24
2821; MIPS32O0-NEXT:  # %bb.3: # %entry
2822; MIPS32O0-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2823; MIPS32O0-NEXT:  # %bb.4: # %entry
2824; MIPS32O0-NEXT:    lw $1, 4($sp) # 4-byte Folded Reload
2825; MIPS32O0-NEXT:    sll $1, $1, 24
2826; MIPS32O0-NEXT:    sra $2, $1, 24
2827; MIPS32O0-NEXT:    addiu $sp, $sp, 8
2828; MIPS32O0-NEXT:    jr $ra
2829; MIPS32O0-NEXT:    nop
2830;
2831; MIPS32R2-LABEL: AtomicLoadSub8:
2832; MIPS32R2:       # %bb.0: # %entry
2833; MIPS32R2-NEXT:    lui $2, %hi(_gp_disp)
2834; MIPS32R2-NEXT:    addiu $2, $2, %lo(_gp_disp)
2835; MIPS32R2-NEXT:    addu $1, $2, $25
2836; MIPS32R2-NEXT:    lw $1, %got(y)($1)
2837; MIPS32R2-NEXT:    addiu $2, $zero, -4
2838; MIPS32R2-NEXT:    and $2, $1, $2
2839; MIPS32R2-NEXT:    andi $1, $1, 3
2840; MIPS32R2-NEXT:    sll $3, $1, 3
2841; MIPS32R2-NEXT:    ori $1, $zero, 255
2842; MIPS32R2-NEXT:    sllv $5, $1, $3
2843; MIPS32R2-NEXT:    nor $6, $zero, $5
2844; MIPS32R2-NEXT:    sllv $4, $4, $3
2845; MIPS32R2-NEXT:  $BB9_1: # %entry
2846; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
2847; MIPS32R2-NEXT:    ll $7, 0($2)
2848; MIPS32R2-NEXT:    subu $8, $7, $4
2849; MIPS32R2-NEXT:    and $8, $8, $5
2850; MIPS32R2-NEXT:    and $9, $7, $6
2851; MIPS32R2-NEXT:    or $9, $9, $8
2852; MIPS32R2-NEXT:    sc $9, 0($2)
2853; MIPS32R2-NEXT:    beqz $9, $BB9_1
2854; MIPS32R2-NEXT:    nop
2855; MIPS32R2-NEXT:  # %bb.2: # %entry
2856; MIPS32R2-NEXT:    and $1, $7, $5
2857; MIPS32R2-NEXT:    srlv $1, $1, $3
2858; MIPS32R2-NEXT:    seb $1, $1
2859; MIPS32R2-NEXT:  # %bb.3: # %entry
2860; MIPS32R2-NEXT:    jr $ra
2861; MIPS32R2-NEXT:    seb $2, $1
2862;
2863; MIPS32R6-LABEL: AtomicLoadSub8:
2864; MIPS32R6:       # %bb.0: # %entry
2865; MIPS32R6-NEXT:    lui $2, %hi(_gp_disp)
2866; MIPS32R6-NEXT:    addiu $2, $2, %lo(_gp_disp)
2867; MIPS32R6-NEXT:    addu $1, $2, $25
2868; MIPS32R6-NEXT:    lw $1, %got(y)($1)
2869; MIPS32R6-NEXT:    addiu $2, $zero, -4
2870; MIPS32R6-NEXT:    and $2, $1, $2
2871; MIPS32R6-NEXT:    andi $1, $1, 3
2872; MIPS32R6-NEXT:    sll $3, $1, 3
2873; MIPS32R6-NEXT:    ori $1, $zero, 255
2874; MIPS32R6-NEXT:    sllv $5, $1, $3
2875; MIPS32R6-NEXT:    nor $6, $zero, $5
2876; MIPS32R6-NEXT:    sllv $4, $4, $3
2877; MIPS32R6-NEXT:  $BB9_1: # %entry
2878; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
2879; MIPS32R6-NEXT:    ll $7, 0($2)
2880; MIPS32R6-NEXT:    subu $8, $7, $4
2881; MIPS32R6-NEXT:    and $8, $8, $5
2882; MIPS32R6-NEXT:    and $9, $7, $6
2883; MIPS32R6-NEXT:    or $9, $9, $8
2884; MIPS32R6-NEXT:    sc $9, 0($2)
2885; MIPS32R6-NEXT:    beqzc $9, $BB9_1
2886; MIPS32R6-NEXT:  # %bb.2: # %entry
2887; MIPS32R6-NEXT:    and $1, $7, $5
2888; MIPS32R6-NEXT:    srlv $1, $1, $3
2889; MIPS32R6-NEXT:    seb $1, $1
2890; MIPS32R6-NEXT:  # %bb.3: # %entry
2891; MIPS32R6-NEXT:    jr $ra
2892; MIPS32R6-NEXT:    seb $2, $1
2893;
2894; MIPS32R6O0-LABEL: AtomicLoadSub8:
2895; MIPS32R6O0:       # %bb.0: # %entry
2896; MIPS32R6O0-NEXT:    lui $2, %hi(_gp_disp)
2897; MIPS32R6O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
2898; MIPS32R6O0-NEXT:    addiu $sp, $sp, -8
2899; MIPS32R6O0-NEXT:    addu $1, $2, $25
2900; MIPS32R6O0-NEXT:    # kill: def $v0 killed $a0
2901; MIPS32R6O0-NEXT:    lw $1, %got(y)($1)
2902; MIPS32R6O0-NEXT:    addiu $2, $zero, -4
2903; MIPS32R6O0-NEXT:    and $5, $1, $2
2904; MIPS32R6O0-NEXT:    andi $1, $1, 3
2905; MIPS32R6O0-NEXT:    sll $9, $1, 3
2906; MIPS32R6O0-NEXT:    ori $1, $zero, 255
2907; MIPS32R6O0-NEXT:    sllv $7, $1, $9
2908; MIPS32R6O0-NEXT:    nor $8, $zero, $7
2909; MIPS32R6O0-NEXT:    sllv $6, $4, $9
2910; MIPS32R6O0-NEXT:  $BB9_1: # %entry
2911; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
2912; MIPS32R6O0-NEXT:    ll $2, 0($5)
2913; MIPS32R6O0-NEXT:    subu $3, $2, $6
2914; MIPS32R6O0-NEXT:    and $3, $3, $7
2915; MIPS32R6O0-NEXT:    and $4, $2, $8
2916; MIPS32R6O0-NEXT:    or $4, $4, $3
2917; MIPS32R6O0-NEXT:    sc $4, 0($5)
2918; MIPS32R6O0-NEXT:    beqzc $4, $BB9_1
2919; MIPS32R6O0-NEXT:  # %bb.2: # %entry
2920; MIPS32R6O0-NEXT:    and $1, $2, $7
2921; MIPS32R6O0-NEXT:    srlv $1, $1, $9
2922; MIPS32R6O0-NEXT:    seb $1, $1
2923; MIPS32R6O0-NEXT:  # %bb.3: # %entry
2924; MIPS32R6O0-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2925; MIPS32R6O0-NEXT:  # %bb.4: # %entry
2926; MIPS32R6O0-NEXT:    lw $1, 4($sp) # 4-byte Folded Reload
2927; MIPS32R6O0-NEXT:    seb $2, $1
2928; MIPS32R6O0-NEXT:    addiu $sp, $sp, 8
2929; MIPS32R6O0-NEXT:    jrc $ra
2930;
2931; MIPS4-LABEL: AtomicLoadSub8:
2932; MIPS4:       # %bb.0: # %entry
2933; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub8)))
2934; MIPS4-NEXT:    daddu $1, $1, $25
2935; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub8)))
2936; MIPS4-NEXT:    ld $1, %got_disp(y)($1)
2937; MIPS4-NEXT:    daddiu $2, $zero, -4
2938; MIPS4-NEXT:    and $2, $1, $2
2939; MIPS4-NEXT:    andi $1, $1, 3
2940; MIPS4-NEXT:    sll $3, $1, 3
2941; MIPS4-NEXT:    ori $1, $zero, 255
2942; MIPS4-NEXT:    sllv $5, $1, $3
2943; MIPS4-NEXT:    nor $6, $zero, $5
2944; MIPS4-NEXT:    sllv $4, $4, $3
2945; MIPS4-NEXT:  .LBB9_1: # %entry
2946; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
2947; MIPS4-NEXT:    ll $7, 0($2)
2948; MIPS4-NEXT:    subu $8, $7, $4
2949; MIPS4-NEXT:    and $8, $8, $5
2950; MIPS4-NEXT:    and $9, $7, $6
2951; MIPS4-NEXT:    or $9, $9, $8
2952; MIPS4-NEXT:    sc $9, 0($2)
2953; MIPS4-NEXT:    beqz $9, .LBB9_1
2954; MIPS4-NEXT:    nop
2955; MIPS4-NEXT:  # %bb.2: # %entry
2956; MIPS4-NEXT:    and $1, $7, $5
2957; MIPS4-NEXT:    srlv $1, $1, $3
2958; MIPS4-NEXT:    sll $1, $1, 24
2959; MIPS4-NEXT:    sra $1, $1, 24
2960; MIPS4-NEXT:  # %bb.3: # %entry
2961; MIPS4-NEXT:    sll $1, $1, 24
2962; MIPS4-NEXT:    jr $ra
2963; MIPS4-NEXT:    sra $2, $1, 24
2964;
2965; MIPS64-LABEL: AtomicLoadSub8:
2966; MIPS64:       # %bb.0: # %entry
2967; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub8)))
2968; MIPS64-NEXT:    daddu $1, $1, $25
2969; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub8)))
2970; MIPS64-NEXT:    ld $1, %got_disp(y)($1)
2971; MIPS64-NEXT:    daddiu $2, $zero, -4
2972; MIPS64-NEXT:    and $2, $1, $2
2973; MIPS64-NEXT:    andi $1, $1, 3
2974; MIPS64-NEXT:    sll $3, $1, 3
2975; MIPS64-NEXT:    ori $1, $zero, 255
2976; MIPS64-NEXT:    sllv $5, $1, $3
2977; MIPS64-NEXT:    nor $6, $zero, $5
2978; MIPS64-NEXT:    sllv $4, $4, $3
2979; MIPS64-NEXT:  .LBB9_1: # %entry
2980; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
2981; MIPS64-NEXT:    ll $7, 0($2)
2982; MIPS64-NEXT:    subu $8, $7, $4
2983; MIPS64-NEXT:    and $8, $8, $5
2984; MIPS64-NEXT:    and $9, $7, $6
2985; MIPS64-NEXT:    or $9, $9, $8
2986; MIPS64-NEXT:    sc $9, 0($2)
2987; MIPS64-NEXT:    beqz $9, .LBB9_1
2988; MIPS64-NEXT:    nop
2989; MIPS64-NEXT:  # %bb.2: # %entry
2990; MIPS64-NEXT:    and $1, $7, $5
2991; MIPS64-NEXT:    srlv $1, $1, $3
2992; MIPS64-NEXT:    sll $1, $1, 24
2993; MIPS64-NEXT:    sra $1, $1, 24
2994; MIPS64-NEXT:  # %bb.3: # %entry
2995; MIPS64-NEXT:    sll $1, $1, 24
2996; MIPS64-NEXT:    jr $ra
2997; MIPS64-NEXT:    sra $2, $1, 24
2998;
2999; MIPS64R2-LABEL: AtomicLoadSub8:
3000; MIPS64R2:       # %bb.0: # %entry
3001; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub8)))
3002; MIPS64R2-NEXT:    daddu $1, $1, $25
3003; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub8)))
3004; MIPS64R2-NEXT:    ld $1, %got_disp(y)($1)
3005; MIPS64R2-NEXT:    daddiu $2, $zero, -4
3006; MIPS64R2-NEXT:    and $2, $1, $2
3007; MIPS64R2-NEXT:    andi $1, $1, 3
3008; MIPS64R2-NEXT:    sll $3, $1, 3
3009; MIPS64R2-NEXT:    ori $1, $zero, 255
3010; MIPS64R2-NEXT:    sllv $5, $1, $3
3011; MIPS64R2-NEXT:    nor $6, $zero, $5
3012; MIPS64R2-NEXT:    sllv $4, $4, $3
3013; MIPS64R2-NEXT:  .LBB9_1: # %entry
3014; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
3015; MIPS64R2-NEXT:    ll $7, 0($2)
3016; MIPS64R2-NEXT:    subu $8, $7, $4
3017; MIPS64R2-NEXT:    and $8, $8, $5
3018; MIPS64R2-NEXT:    and $9, $7, $6
3019; MIPS64R2-NEXT:    or $9, $9, $8
3020; MIPS64R2-NEXT:    sc $9, 0($2)
3021; MIPS64R2-NEXT:    beqz $9, .LBB9_1
3022; MIPS64R2-NEXT:    nop
3023; MIPS64R2-NEXT:  # %bb.2: # %entry
3024; MIPS64R2-NEXT:    and $1, $7, $5
3025; MIPS64R2-NEXT:    srlv $1, $1, $3
3026; MIPS64R2-NEXT:    seb $1, $1
3027; MIPS64R2-NEXT:  # %bb.3: # %entry
3028; MIPS64R2-NEXT:    jr $ra
3029; MIPS64R2-NEXT:    seb $2, $1
3030;
3031; MIPS64R6-LABEL: AtomicLoadSub8:
3032; MIPS64R6:       # %bb.0: # %entry
3033; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub8)))
3034; MIPS64R6-NEXT:    daddu $1, $1, $25
3035; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadSub8)))
3036; MIPS64R6-NEXT:    ld $1, %got_disp(y)($1)
3037; MIPS64R6-NEXT:    daddiu $2, $zero, -4
3038; MIPS64R6-NEXT:    and $2, $1, $2
3039; MIPS64R6-NEXT:    andi $1, $1, 3
3040; MIPS64R6-NEXT:    sll $3, $1, 3
3041; MIPS64R6-NEXT:    ori $1, $zero, 255
3042; MIPS64R6-NEXT:    sllv $5, $1, $3
3043; MIPS64R6-NEXT:    nor $6, $zero, $5
3044; MIPS64R6-NEXT:    sllv $4, $4, $3
3045; MIPS64R6-NEXT:  .LBB9_1: # %entry
3046; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
3047; MIPS64R6-NEXT:    ll $7, 0($2)
3048; MIPS64R6-NEXT:    subu $8, $7, $4
3049; MIPS64R6-NEXT:    and $8, $8, $5
3050; MIPS64R6-NEXT:    and $9, $7, $6
3051; MIPS64R6-NEXT:    or $9, $9, $8
3052; MIPS64R6-NEXT:    sc $9, 0($2)
3053; MIPS64R6-NEXT:    beqzc $9, .LBB9_1
3054; MIPS64R6-NEXT:  # %bb.2: # %entry
3055; MIPS64R6-NEXT:    and $1, $7, $5
3056; MIPS64R6-NEXT:    srlv $1, $1, $3
3057; MIPS64R6-NEXT:    seb $1, $1
3058; MIPS64R6-NEXT:  # %bb.3: # %entry
3059; MIPS64R6-NEXT:    jr $ra
3060; MIPS64R6-NEXT:    seb $2, $1
3061;
3062; MIPS64R6O0-LABEL: AtomicLoadSub8:
3063; MIPS64R6O0:       # %bb.0: # %entry
3064; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -16
3065; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadSub8)))
3066; MIPS64R6O0-NEXT:    daddu $1, $1, $25
3067; MIPS64R6O0-NEXT:    daddiu $2, $1, %lo(%neg(%gp_rel(AtomicLoadSub8)))
3068; MIPS64R6O0-NEXT:    move $1, $4
3069; MIPS64R6O0-NEXT:    ld $2, %got_disp(y)($2)
3070; MIPS64R6O0-NEXT:    daddiu $3, $zero, -4
3071; MIPS64R6O0-NEXT:    and $5, $2, $3
3072; MIPS64R6O0-NEXT:    andi $2, $2, 3
3073; MIPS64R6O0-NEXT:    xori $2, $2, 3
3074; MIPS64R6O0-NEXT:    sll $9, $2, 3
3075; MIPS64R6O0-NEXT:    ori $2, $zero, 255
3076; MIPS64R6O0-NEXT:    sllv $7, $2, $9
3077; MIPS64R6O0-NEXT:    nor $8, $zero, $7
3078; MIPS64R6O0-NEXT:    sllv $6, $1, $9
3079; MIPS64R6O0-NEXT:  .LBB9_1: # %entry
3080; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
3081; MIPS64R6O0-NEXT:    ll $2, 0($5)
3082; MIPS64R6O0-NEXT:    subu $3, $2, $6
3083; MIPS64R6O0-NEXT:    and $3, $3, $7
3084; MIPS64R6O0-NEXT:    and $4, $2, $8
3085; MIPS64R6O0-NEXT:    or $4, $4, $3
3086; MIPS64R6O0-NEXT:    sc $4, 0($5)
3087; MIPS64R6O0-NEXT:    beqzc $4, .LBB9_1
3088; MIPS64R6O0-NEXT:  # %bb.2: # %entry
3089; MIPS64R6O0-NEXT:    and $1, $2, $7
3090; MIPS64R6O0-NEXT:    srlv $1, $1, $9
3091; MIPS64R6O0-NEXT:    seb $1, $1
3092; MIPS64R6O0-NEXT:  # %bb.3: # %entry
3093; MIPS64R6O0-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
3094; MIPS64R6O0-NEXT:  # %bb.4: # %entry
3095; MIPS64R6O0-NEXT:    lw $1, 12($sp) # 4-byte Folded Reload
3096; MIPS64R6O0-NEXT:    seb $2, $1
3097; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 16
3098; MIPS64R6O0-NEXT:    jrc $ra
3099;
3100; MM32-LABEL: AtomicLoadSub8:
3101; MM32:       # %bb.0: # %entry
3102; MM32-NEXT:    lui $2, %hi(_gp_disp)
3103; MM32-NEXT:    addiu $2, $2, %lo(_gp_disp)
3104; MM32-NEXT:    addu $2, $2, $25
3105; MM32-NEXT:    lw $1, %got(y)($2)
3106; MM32-NEXT:    addiu $2, $zero, -4
3107; MM32-NEXT:    and $2, $1, $2
3108; MM32-NEXT:    andi $1, $1, 3
3109; MM32-NEXT:    sll $3, $1, 3
3110; MM32-NEXT:    ori $1, $zero, 255
3111; MM32-NEXT:    sllv $5, $1, $3
3112; MM32-NEXT:    nor $6, $zero, $5
3113; MM32-NEXT:    sllv $4, $4, $3
3114; MM32-NEXT:  $BB9_1: # %entry
3115; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
3116; MM32-NEXT:    ll $7, 0($2)
3117; MM32-NEXT:    subu $8, $7, $4
3118; MM32-NEXT:    and $8, $8, $5
3119; MM32-NEXT:    and $9, $7, $6
3120; MM32-NEXT:    or $9, $9, $8
3121; MM32-NEXT:    sc $9, 0($2)
3122; MM32-NEXT:    beqzc $9, $BB9_1
3123; MM32-NEXT:  # %bb.2: # %entry
3124; MM32-NEXT:    and $1, $7, $5
3125; MM32-NEXT:    srlv $1, $1, $3
3126; MM32-NEXT:    seb $1, $1
3127; MM32-NEXT:  # %bb.3: # %entry
3128; MM32-NEXT:    jr $ra
3129; MM32-NEXT:    seb $2, $1
3130;
3131; O1-LABEL: AtomicLoadSub8:
3132; O1:       # %bb.0: # %entry
3133; O1-NEXT:    lui $2, %hi(_gp_disp)
3134; O1-NEXT:    addiu $2, $2, %lo(_gp_disp)
3135; O1-NEXT:    addu $1, $2, $25
3136; O1-NEXT:    lw $1, %got(y)($1)
3137; O1-NEXT:    addiu $2, $zero, -4
3138; O1-NEXT:    and $2, $1, $2
3139; O1-NEXT:    andi $1, $1, 3
3140; O1-NEXT:    sll $3, $1, 3
3141; O1-NEXT:    ori $1, $zero, 255
3142; O1-NEXT:    sllv $5, $1, $3
3143; O1-NEXT:    nor $6, $zero, $5
3144; O1-NEXT:    sllv $4, $4, $3
3145; O1-NEXT:  $BB9_1: # %entry
3146; O1-NEXT:    # =>This Inner Loop Header: Depth=1
3147; O1-NEXT:    ll $7, 0($2)
3148; O1-NEXT:    subu $8, $7, $4
3149; O1-NEXT:    and $8, $8, $5
3150; O1-NEXT:    and $9, $7, $6
3151; O1-NEXT:    or $9, $9, $8
3152; O1-NEXT:    sc $9, 0($2)
3153; O1-NEXT:    beqz $9, $BB9_1
3154; O1-NEXT:    nop
3155; O1-NEXT:  # %bb.2: # %entry
3156; O1-NEXT:    and $1, $7, $5
3157; O1-NEXT:    srlv $1, $1, $3
3158; O1-NEXT:    sll $1, $1, 24
3159; O1-NEXT:    sra $1, $1, 24
3160; O1-NEXT:  # %bb.3: # %entry
3161; O1-NEXT:    sll $1, $1, 24
3162; O1-NEXT:    jr $ra
3163; O1-NEXT:    sra $2, $1, 24
3164;
3165; O2-LABEL: AtomicLoadSub8:
3166; O2:       # %bb.0: # %entry
3167; O2-NEXT:    lui $2, %hi(_gp_disp)
3168; O2-NEXT:    addiu $2, $2, %lo(_gp_disp)
3169; O2-NEXT:    addu $1, $2, $25
3170; O2-NEXT:    lw $1, %got(y)($1)
3171; O2-NEXT:    addiu $2, $zero, -4
3172; O2-NEXT:    and $2, $1, $2
3173; O2-NEXT:    andi $1, $1, 3
3174; O2-NEXT:    sll $3, $1, 3
3175; O2-NEXT:    ori $1, $zero, 255
3176; O2-NEXT:    sllv $5, $1, $3
3177; O2-NEXT:    nor $6, $zero, $5
3178; O2-NEXT:    sllv $4, $4, $3
3179; O2-NEXT:  $BB9_1: # %entry
3180; O2-NEXT:    # =>This Inner Loop Header: Depth=1
3181; O2-NEXT:    ll $7, 0($2)
3182; O2-NEXT:    subu $8, $7, $4
3183; O2-NEXT:    and $8, $8, $5
3184; O2-NEXT:    and $9, $7, $6
3185; O2-NEXT:    or $9, $9, $8
3186; O2-NEXT:    sc $9, 0($2)
3187; O2-NEXT:    beqz $9, $BB9_1
3188; O2-NEXT:    nop
3189; O2-NEXT:  # %bb.2: # %entry
3190; O2-NEXT:    and $1, $7, $5
3191; O2-NEXT:    srlv $1, $1, $3
3192; O2-NEXT:    sll $1, $1, 24
3193; O2-NEXT:    sra $1, $1, 24
3194; O2-NEXT:  # %bb.3: # %entry
3195; O2-NEXT:    sll $1, $1, 24
3196; O2-NEXT:    jr $ra
3197; O2-NEXT:    sra $2, $1, 24
3198;
3199; O3-LABEL: AtomicLoadSub8:
3200; O3:       # %bb.0: # %entry
3201; O3-NEXT:    lui $2, %hi(_gp_disp)
3202; O3-NEXT:    addiu $2, $2, %lo(_gp_disp)
3203; O3-NEXT:    addu $1, $2, $25
3204; O3-NEXT:    addiu $2, $zero, -4
3205; O3-NEXT:    lw $1, %got(y)($1)
3206; O3-NEXT:    and $2, $1, $2
3207; O3-NEXT:    andi $1, $1, 3
3208; O3-NEXT:    sll $3, $1, 3
3209; O3-NEXT:    ori $1, $zero, 255
3210; O3-NEXT:    sllv $5, $1, $3
3211; O3-NEXT:    sllv $4, $4, $3
3212; O3-NEXT:    nor $6, $zero, $5
3213; O3-NEXT:  $BB9_1: # %entry
3214; O3-NEXT:    # =>This Inner Loop Header: Depth=1
3215; O3-NEXT:    ll $7, 0($2)
3216; O3-NEXT:    subu $8, $7, $4
3217; O3-NEXT:    and $8, $8, $5
3218; O3-NEXT:    and $9, $7, $6
3219; O3-NEXT:    or $9, $9, $8
3220; O3-NEXT:    sc $9, 0($2)
3221; O3-NEXT:    beqz $9, $BB9_1
3222; O3-NEXT:    nop
3223; O3-NEXT:  # %bb.2: # %entry
3224; O3-NEXT:    and $1, $7, $5
3225; O3-NEXT:    srlv $1, $1, $3
3226; O3-NEXT:    sll $1, $1, 24
3227; O3-NEXT:    sra $1, $1, 24
3228; O3-NEXT:  # %bb.3: # %entry
3229; O3-NEXT:    sll $1, $1, 24
3230; O3-NEXT:    jr $ra
3231; O3-NEXT:    sra $2, $1, 24
3232;
3233; MIPS32EB-LABEL: AtomicLoadSub8:
3234; MIPS32EB:       # %bb.0: # %entry
3235; MIPS32EB-NEXT:    lui $2, %hi(_gp_disp)
3236; MIPS32EB-NEXT:    addiu $2, $2, %lo(_gp_disp)
3237; MIPS32EB-NEXT:    addu $1, $2, $25
3238; MIPS32EB-NEXT:    lw $1, %got(y)($1)
3239; MIPS32EB-NEXT:    addiu $2, $zero, -4
3240; MIPS32EB-NEXT:    and $2, $1, $2
3241; MIPS32EB-NEXT:    andi $1, $1, 3
3242; MIPS32EB-NEXT:    xori $1, $1, 3
3243; MIPS32EB-NEXT:    sll $3, $1, 3
3244; MIPS32EB-NEXT:    ori $1, $zero, 255
3245; MIPS32EB-NEXT:    sllv $5, $1, $3
3246; MIPS32EB-NEXT:    nor $6, $zero, $5
3247; MIPS32EB-NEXT:    sllv $4, $4, $3
3248; MIPS32EB-NEXT:  $BB9_1: # %entry
3249; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
3250; MIPS32EB-NEXT:    ll $7, 0($2)
3251; MIPS32EB-NEXT:    subu $8, $7, $4
3252; MIPS32EB-NEXT:    and $8, $8, $5
3253; MIPS32EB-NEXT:    and $9, $7, $6
3254; MIPS32EB-NEXT:    or $9, $9, $8
3255; MIPS32EB-NEXT:    sc $9, 0($2)
3256; MIPS32EB-NEXT:    beqz $9, $BB9_1
3257; MIPS32EB-NEXT:    nop
3258; MIPS32EB-NEXT:  # %bb.2: # %entry
3259; MIPS32EB-NEXT:    and $1, $7, $5
3260; MIPS32EB-NEXT:    srlv $1, $1, $3
3261; MIPS32EB-NEXT:    sll $1, $1, 24
3262; MIPS32EB-NEXT:    sra $1, $1, 24
3263; MIPS32EB-NEXT:  # %bb.3: # %entry
3264; MIPS32EB-NEXT:    sll $1, $1, 24
3265; MIPS32EB-NEXT:    jr $ra
3266; MIPS32EB-NEXT:    sra $2, $1, 24
3267entry:
3268  %0 = atomicrmw sub i8* @y, i8 %incr monotonic
3269  ret i8 %0
3270
3271}
3272
3273define signext i8 @AtomicLoadNand8(i8 signext %incr) nounwind {
3274; MIPS32-LABEL: AtomicLoadNand8:
3275; MIPS32:       # %bb.0: # %entry
3276; MIPS32-NEXT:    lui $2, %hi(_gp_disp)
3277; MIPS32-NEXT:    addiu $2, $2, %lo(_gp_disp)
3278; MIPS32-NEXT:    addu $1, $2, $25
3279; MIPS32-NEXT:    lw $1, %got(y)($1)
3280; MIPS32-NEXT:    addiu $2, $zero, -4
3281; MIPS32-NEXT:    and $2, $1, $2
3282; MIPS32-NEXT:    andi $1, $1, 3
3283; MIPS32-NEXT:    sll $3, $1, 3
3284; MIPS32-NEXT:    ori $1, $zero, 255
3285; MIPS32-NEXT:    sllv $5, $1, $3
3286; MIPS32-NEXT:    nor $6, $zero, $5
3287; MIPS32-NEXT:    sllv $4, $4, $3
3288; MIPS32-NEXT:  $BB10_1: # %entry
3289; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
3290; MIPS32-NEXT:    ll $7, 0($2)
3291; MIPS32-NEXT:    and $8, $7, $4
3292; MIPS32-NEXT:    nor $8, $zero, $8
3293; MIPS32-NEXT:    and $8, $8, $5
3294; MIPS32-NEXT:    and $9, $7, $6
3295; MIPS32-NEXT:    or $9, $9, $8
3296; MIPS32-NEXT:    sc $9, 0($2)
3297; MIPS32-NEXT:    beqz $9, $BB10_1
3298; MIPS32-NEXT:    nop
3299; MIPS32-NEXT:  # %bb.2: # %entry
3300; MIPS32-NEXT:    and $1, $7, $5
3301; MIPS32-NEXT:    srlv $1, $1, $3
3302; MIPS32-NEXT:    sll $1, $1, 24
3303; MIPS32-NEXT:    sra $1, $1, 24
3304; MIPS32-NEXT:  # %bb.3: # %entry
3305; MIPS32-NEXT:    sll $1, $1, 24
3306; MIPS32-NEXT:    jr $ra
3307; MIPS32-NEXT:    sra $2, $1, 24
3308;
3309; MIPS32O0-LABEL: AtomicLoadNand8:
3310; MIPS32O0:       # %bb.0: # %entry
3311; MIPS32O0-NEXT:    lui $2, %hi(_gp_disp)
3312; MIPS32O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
3313; MIPS32O0-NEXT:    addiu $sp, $sp, -8
3314; MIPS32O0-NEXT:    addu $1, $2, $25
3315; MIPS32O0-NEXT:    lw $1, %got(y)($1)
3316; MIPS32O0-NEXT:    addiu $2, $zero, -4
3317; MIPS32O0-NEXT:    and $5, $1, $2
3318; MIPS32O0-NEXT:    andi $1, $1, 3
3319; MIPS32O0-NEXT:    sll $9, $1, 3
3320; MIPS32O0-NEXT:    ori $1, $zero, 255
3321; MIPS32O0-NEXT:    sllv $7, $1, $9
3322; MIPS32O0-NEXT:    nor $8, $zero, $7
3323; MIPS32O0-NEXT:    sllv $6, $4, $9
3324; MIPS32O0-NEXT:  $BB10_1: # %entry
3325; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
3326; MIPS32O0-NEXT:    ll $2, 0($5)
3327; MIPS32O0-NEXT:    and $3, $2, $6
3328; MIPS32O0-NEXT:    nor $3, $zero, $3
3329; MIPS32O0-NEXT:    and $3, $3, $7
3330; MIPS32O0-NEXT:    and $4, $2, $8
3331; MIPS32O0-NEXT:    or $4, $4, $3
3332; MIPS32O0-NEXT:    sc $4, 0($5)
3333; MIPS32O0-NEXT:    beqz $4, $BB10_1
3334; MIPS32O0-NEXT:    nop
3335; MIPS32O0-NEXT:  # %bb.2: # %entry
3336; MIPS32O0-NEXT:    and $1, $2, $7
3337; MIPS32O0-NEXT:    srlv $1, $1, $9
3338; MIPS32O0-NEXT:    sll $1, $1, 24
3339; MIPS32O0-NEXT:    sra $1, $1, 24
3340; MIPS32O0-NEXT:  # %bb.3: # %entry
3341; MIPS32O0-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3342; MIPS32O0-NEXT:  # %bb.4: # %entry
3343; MIPS32O0-NEXT:    lw $1, 4($sp) # 4-byte Folded Reload
3344; MIPS32O0-NEXT:    sll $1, $1, 24
3345; MIPS32O0-NEXT:    sra $2, $1, 24
3346; MIPS32O0-NEXT:    addiu $sp, $sp, 8
3347; MIPS32O0-NEXT:    jr $ra
3348; MIPS32O0-NEXT:    nop
3349;
3350; MIPS32R2-LABEL: AtomicLoadNand8:
3351; MIPS32R2:       # %bb.0: # %entry
3352; MIPS32R2-NEXT:    lui $2, %hi(_gp_disp)
3353; MIPS32R2-NEXT:    addiu $2, $2, %lo(_gp_disp)
3354; MIPS32R2-NEXT:    addu $1, $2, $25
3355; MIPS32R2-NEXT:    lw $1, %got(y)($1)
3356; MIPS32R2-NEXT:    addiu $2, $zero, -4
3357; MIPS32R2-NEXT:    and $2, $1, $2
3358; MIPS32R2-NEXT:    andi $1, $1, 3
3359; MIPS32R2-NEXT:    sll $3, $1, 3
3360; MIPS32R2-NEXT:    ori $1, $zero, 255
3361; MIPS32R2-NEXT:    sllv $5, $1, $3
3362; MIPS32R2-NEXT:    nor $6, $zero, $5
3363; MIPS32R2-NEXT:    sllv $4, $4, $3
3364; MIPS32R2-NEXT:  $BB10_1: # %entry
3365; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
3366; MIPS32R2-NEXT:    ll $7, 0($2)
3367; MIPS32R2-NEXT:    and $8, $7, $4
3368; MIPS32R2-NEXT:    nor $8, $zero, $8
3369; MIPS32R2-NEXT:    and $8, $8, $5
3370; MIPS32R2-NEXT:    and $9, $7, $6
3371; MIPS32R2-NEXT:    or $9, $9, $8
3372; MIPS32R2-NEXT:    sc $9, 0($2)
3373; MIPS32R2-NEXT:    beqz $9, $BB10_1
3374; MIPS32R2-NEXT:    nop
3375; MIPS32R2-NEXT:  # %bb.2: # %entry
3376; MIPS32R2-NEXT:    and $1, $7, $5
3377; MIPS32R2-NEXT:    srlv $1, $1, $3
3378; MIPS32R2-NEXT:    seb $1, $1
3379; MIPS32R2-NEXT:  # %bb.3: # %entry
3380; MIPS32R2-NEXT:    jr $ra
3381; MIPS32R2-NEXT:    seb $2, $1
3382;
3383; MIPS32R6-LABEL: AtomicLoadNand8:
3384; MIPS32R6:       # %bb.0: # %entry
3385; MIPS32R6-NEXT:    lui $2, %hi(_gp_disp)
3386; MIPS32R6-NEXT:    addiu $2, $2, %lo(_gp_disp)
3387; MIPS32R6-NEXT:    addu $1, $2, $25
3388; MIPS32R6-NEXT:    lw $1, %got(y)($1)
3389; MIPS32R6-NEXT:    addiu $2, $zero, -4
3390; MIPS32R6-NEXT:    and $2, $1, $2
3391; MIPS32R6-NEXT:    andi $1, $1, 3
3392; MIPS32R6-NEXT:    sll $3, $1, 3
3393; MIPS32R6-NEXT:    ori $1, $zero, 255
3394; MIPS32R6-NEXT:    sllv $5, $1, $3
3395; MIPS32R6-NEXT:    nor $6, $zero, $5
3396; MIPS32R6-NEXT:    sllv $4, $4, $3
3397; MIPS32R6-NEXT:  $BB10_1: # %entry
3398; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
3399; MIPS32R6-NEXT:    ll $7, 0($2)
3400; MIPS32R6-NEXT:    and $8, $7, $4
3401; MIPS32R6-NEXT:    nor $8, $zero, $8
3402; MIPS32R6-NEXT:    and $8, $8, $5
3403; MIPS32R6-NEXT:    and $9, $7, $6
3404; MIPS32R6-NEXT:    or $9, $9, $8
3405; MIPS32R6-NEXT:    sc $9, 0($2)
3406; MIPS32R6-NEXT:    beqzc $9, $BB10_1
3407; MIPS32R6-NEXT:  # %bb.2: # %entry
3408; MIPS32R6-NEXT:    and $1, $7, $5
3409; MIPS32R6-NEXT:    srlv $1, $1, $3
3410; MIPS32R6-NEXT:    seb $1, $1
3411; MIPS32R6-NEXT:  # %bb.3: # %entry
3412; MIPS32R6-NEXT:    jr $ra
3413; MIPS32R6-NEXT:    seb $2, $1
3414;
3415; MIPS32R6O0-LABEL: AtomicLoadNand8:
3416; MIPS32R6O0:       # %bb.0: # %entry
3417; MIPS32R6O0-NEXT:    lui $2, %hi(_gp_disp)
3418; MIPS32R6O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
3419; MIPS32R6O0-NEXT:    addiu $sp, $sp, -8
3420; MIPS32R6O0-NEXT:    addu $1, $2, $25
3421; MIPS32R6O0-NEXT:    # kill: def $v0 killed $a0
3422; MIPS32R6O0-NEXT:    lw $1, %got(y)($1)
3423; MIPS32R6O0-NEXT:    addiu $2, $zero, -4
3424; MIPS32R6O0-NEXT:    and $5, $1, $2
3425; MIPS32R6O0-NEXT:    andi $1, $1, 3
3426; MIPS32R6O0-NEXT:    sll $9, $1, 3
3427; MIPS32R6O0-NEXT:    ori $1, $zero, 255
3428; MIPS32R6O0-NEXT:    sllv $7, $1, $9
3429; MIPS32R6O0-NEXT:    nor $8, $zero, $7
3430; MIPS32R6O0-NEXT:    sllv $6, $4, $9
3431; MIPS32R6O0-NEXT:  $BB10_1: # %entry
3432; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
3433; MIPS32R6O0-NEXT:    ll $2, 0($5)
3434; MIPS32R6O0-NEXT:    and $3, $2, $6
3435; MIPS32R6O0-NEXT:    nor $3, $zero, $3
3436; MIPS32R6O0-NEXT:    and $3, $3, $7
3437; MIPS32R6O0-NEXT:    and $4, $2, $8
3438; MIPS32R6O0-NEXT:    or $4, $4, $3
3439; MIPS32R6O0-NEXT:    sc $4, 0($5)
3440; MIPS32R6O0-NEXT:    beqzc $4, $BB10_1
3441; MIPS32R6O0-NEXT:  # %bb.2: # %entry
3442; MIPS32R6O0-NEXT:    and $1, $2, $7
3443; MIPS32R6O0-NEXT:    srlv $1, $1, $9
3444; MIPS32R6O0-NEXT:    seb $1, $1
3445; MIPS32R6O0-NEXT:  # %bb.3: # %entry
3446; MIPS32R6O0-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3447; MIPS32R6O0-NEXT:  # %bb.4: # %entry
3448; MIPS32R6O0-NEXT:    lw $1, 4($sp) # 4-byte Folded Reload
3449; MIPS32R6O0-NEXT:    seb $2, $1
3450; MIPS32R6O0-NEXT:    addiu $sp, $sp, 8
3451; MIPS32R6O0-NEXT:    jrc $ra
3452;
3453; MIPS4-LABEL: AtomicLoadNand8:
3454; MIPS4:       # %bb.0: # %entry
3455; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand8)))
3456; MIPS4-NEXT:    daddu $1, $1, $25
3457; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand8)))
3458; MIPS4-NEXT:    ld $1, %got_disp(y)($1)
3459; MIPS4-NEXT:    daddiu $2, $zero, -4
3460; MIPS4-NEXT:    and $2, $1, $2
3461; MIPS4-NEXT:    andi $1, $1, 3
3462; MIPS4-NEXT:    sll $3, $1, 3
3463; MIPS4-NEXT:    ori $1, $zero, 255
3464; MIPS4-NEXT:    sllv $5, $1, $3
3465; MIPS4-NEXT:    nor $6, $zero, $5
3466; MIPS4-NEXT:    sllv $4, $4, $3
3467; MIPS4-NEXT:  .LBB10_1: # %entry
3468; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
3469; MIPS4-NEXT:    ll $7, 0($2)
3470; MIPS4-NEXT:    and $8, $7, $4
3471; MIPS4-NEXT:    nor $8, $zero, $8
3472; MIPS4-NEXT:    and $8, $8, $5
3473; MIPS4-NEXT:    and $9, $7, $6
3474; MIPS4-NEXT:    or $9, $9, $8
3475; MIPS4-NEXT:    sc $9, 0($2)
3476; MIPS4-NEXT:    beqz $9, .LBB10_1
3477; MIPS4-NEXT:    nop
3478; MIPS4-NEXT:  # %bb.2: # %entry
3479; MIPS4-NEXT:    and $1, $7, $5
3480; MIPS4-NEXT:    srlv $1, $1, $3
3481; MIPS4-NEXT:    sll $1, $1, 24
3482; MIPS4-NEXT:    sra $1, $1, 24
3483; MIPS4-NEXT:  # %bb.3: # %entry
3484; MIPS4-NEXT:    sll $1, $1, 24
3485; MIPS4-NEXT:    jr $ra
3486; MIPS4-NEXT:    sra $2, $1, 24
3487;
3488; MIPS64-LABEL: AtomicLoadNand8:
3489; MIPS64:       # %bb.0: # %entry
3490; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand8)))
3491; MIPS64-NEXT:    daddu $1, $1, $25
3492; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand8)))
3493; MIPS64-NEXT:    ld $1, %got_disp(y)($1)
3494; MIPS64-NEXT:    daddiu $2, $zero, -4
3495; MIPS64-NEXT:    and $2, $1, $2
3496; MIPS64-NEXT:    andi $1, $1, 3
3497; MIPS64-NEXT:    sll $3, $1, 3
3498; MIPS64-NEXT:    ori $1, $zero, 255
3499; MIPS64-NEXT:    sllv $5, $1, $3
3500; MIPS64-NEXT:    nor $6, $zero, $5
3501; MIPS64-NEXT:    sllv $4, $4, $3
3502; MIPS64-NEXT:  .LBB10_1: # %entry
3503; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
3504; MIPS64-NEXT:    ll $7, 0($2)
3505; MIPS64-NEXT:    and $8, $7, $4
3506; MIPS64-NEXT:    nor $8, $zero, $8
3507; MIPS64-NEXT:    and $8, $8, $5
3508; MIPS64-NEXT:    and $9, $7, $6
3509; MIPS64-NEXT:    or $9, $9, $8
3510; MIPS64-NEXT:    sc $9, 0($2)
3511; MIPS64-NEXT:    beqz $9, .LBB10_1
3512; MIPS64-NEXT:    nop
3513; MIPS64-NEXT:  # %bb.2: # %entry
3514; MIPS64-NEXT:    and $1, $7, $5
3515; MIPS64-NEXT:    srlv $1, $1, $3
3516; MIPS64-NEXT:    sll $1, $1, 24
3517; MIPS64-NEXT:    sra $1, $1, 24
3518; MIPS64-NEXT:  # %bb.3: # %entry
3519; MIPS64-NEXT:    sll $1, $1, 24
3520; MIPS64-NEXT:    jr $ra
3521; MIPS64-NEXT:    sra $2, $1, 24
3522;
3523; MIPS64R2-LABEL: AtomicLoadNand8:
3524; MIPS64R2:       # %bb.0: # %entry
3525; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand8)))
3526; MIPS64R2-NEXT:    daddu $1, $1, $25
3527; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand8)))
3528; MIPS64R2-NEXT:    ld $1, %got_disp(y)($1)
3529; MIPS64R2-NEXT:    daddiu $2, $zero, -4
3530; MIPS64R2-NEXT:    and $2, $1, $2
3531; MIPS64R2-NEXT:    andi $1, $1, 3
3532; MIPS64R2-NEXT:    sll $3, $1, 3
3533; MIPS64R2-NEXT:    ori $1, $zero, 255
3534; MIPS64R2-NEXT:    sllv $5, $1, $3
3535; MIPS64R2-NEXT:    nor $6, $zero, $5
3536; MIPS64R2-NEXT:    sllv $4, $4, $3
3537; MIPS64R2-NEXT:  .LBB10_1: # %entry
3538; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
3539; MIPS64R2-NEXT:    ll $7, 0($2)
3540; MIPS64R2-NEXT:    and $8, $7, $4
3541; MIPS64R2-NEXT:    nor $8, $zero, $8
3542; MIPS64R2-NEXT:    and $8, $8, $5
3543; MIPS64R2-NEXT:    and $9, $7, $6
3544; MIPS64R2-NEXT:    or $9, $9, $8
3545; MIPS64R2-NEXT:    sc $9, 0($2)
3546; MIPS64R2-NEXT:    beqz $9, .LBB10_1
3547; MIPS64R2-NEXT:    nop
3548; MIPS64R2-NEXT:  # %bb.2: # %entry
3549; MIPS64R2-NEXT:    and $1, $7, $5
3550; MIPS64R2-NEXT:    srlv $1, $1, $3
3551; MIPS64R2-NEXT:    seb $1, $1
3552; MIPS64R2-NEXT:  # %bb.3: # %entry
3553; MIPS64R2-NEXT:    jr $ra
3554; MIPS64R2-NEXT:    seb $2, $1
3555;
3556; MIPS64R6-LABEL: AtomicLoadNand8:
3557; MIPS64R6:       # %bb.0: # %entry
3558; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand8)))
3559; MIPS64R6-NEXT:    daddu $1, $1, $25
3560; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadNand8)))
3561; MIPS64R6-NEXT:    ld $1, %got_disp(y)($1)
3562; MIPS64R6-NEXT:    daddiu $2, $zero, -4
3563; MIPS64R6-NEXT:    and $2, $1, $2
3564; MIPS64R6-NEXT:    andi $1, $1, 3
3565; MIPS64R6-NEXT:    sll $3, $1, 3
3566; MIPS64R6-NEXT:    ori $1, $zero, 255
3567; MIPS64R6-NEXT:    sllv $5, $1, $3
3568; MIPS64R6-NEXT:    nor $6, $zero, $5
3569; MIPS64R6-NEXT:    sllv $4, $4, $3
3570; MIPS64R6-NEXT:  .LBB10_1: # %entry
3571; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
3572; MIPS64R6-NEXT:    ll $7, 0($2)
3573; MIPS64R6-NEXT:    and $8, $7, $4
3574; MIPS64R6-NEXT:    nor $8, $zero, $8
3575; MIPS64R6-NEXT:    and $8, $8, $5
3576; MIPS64R6-NEXT:    and $9, $7, $6
3577; MIPS64R6-NEXT:    or $9, $9, $8
3578; MIPS64R6-NEXT:    sc $9, 0($2)
3579; MIPS64R6-NEXT:    beqzc $9, .LBB10_1
3580; MIPS64R6-NEXT:  # %bb.2: # %entry
3581; MIPS64R6-NEXT:    and $1, $7, $5
3582; MIPS64R6-NEXT:    srlv $1, $1, $3
3583; MIPS64R6-NEXT:    seb $1, $1
3584; MIPS64R6-NEXT:  # %bb.3: # %entry
3585; MIPS64R6-NEXT:    jr $ra
3586; MIPS64R6-NEXT:    seb $2, $1
3587;
3588; MIPS64R6O0-LABEL: AtomicLoadNand8:
3589; MIPS64R6O0:       # %bb.0: # %entry
3590; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -16
3591; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadNand8)))
3592; MIPS64R6O0-NEXT:    daddu $1, $1, $25
3593; MIPS64R6O0-NEXT:    daddiu $2, $1, %lo(%neg(%gp_rel(AtomicLoadNand8)))
3594; MIPS64R6O0-NEXT:    move $1, $4
3595; MIPS64R6O0-NEXT:    ld $2, %got_disp(y)($2)
3596; MIPS64R6O0-NEXT:    daddiu $3, $zero, -4
3597; MIPS64R6O0-NEXT:    and $5, $2, $3
3598; MIPS64R6O0-NEXT:    andi $2, $2, 3
3599; MIPS64R6O0-NEXT:    xori $2, $2, 3
3600; MIPS64R6O0-NEXT:    sll $9, $2, 3
3601; MIPS64R6O0-NEXT:    ori $2, $zero, 255
3602; MIPS64R6O0-NEXT:    sllv $7, $2, $9
3603; MIPS64R6O0-NEXT:    nor $8, $zero, $7
3604; MIPS64R6O0-NEXT:    sllv $6, $1, $9
3605; MIPS64R6O0-NEXT:  .LBB10_1: # %entry
3606; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
3607; MIPS64R6O0-NEXT:    ll $2, 0($5)
3608; MIPS64R6O0-NEXT:    and $3, $2, $6
3609; MIPS64R6O0-NEXT:    nor $3, $zero, $3
3610; MIPS64R6O0-NEXT:    and $3, $3, $7
3611; MIPS64R6O0-NEXT:    and $4, $2, $8
3612; MIPS64R6O0-NEXT:    or $4, $4, $3
3613; MIPS64R6O0-NEXT:    sc $4, 0($5)
3614; MIPS64R6O0-NEXT:    beqzc $4, .LBB10_1
3615; MIPS64R6O0-NEXT:  # %bb.2: # %entry
3616; MIPS64R6O0-NEXT:    and $1, $2, $7
3617; MIPS64R6O0-NEXT:    srlv $1, $1, $9
3618; MIPS64R6O0-NEXT:    seb $1, $1
3619; MIPS64R6O0-NEXT:  # %bb.3: # %entry
3620; MIPS64R6O0-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
3621; MIPS64R6O0-NEXT:  # %bb.4: # %entry
3622; MIPS64R6O0-NEXT:    lw $1, 12($sp) # 4-byte Folded Reload
3623; MIPS64R6O0-NEXT:    seb $2, $1
3624; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 16
3625; MIPS64R6O0-NEXT:    jrc $ra
3626;
3627; MM32-LABEL: AtomicLoadNand8:
3628; MM32:       # %bb.0: # %entry
3629; MM32-NEXT:    lui $2, %hi(_gp_disp)
3630; MM32-NEXT:    addiu $2, $2, %lo(_gp_disp)
3631; MM32-NEXT:    addu $2, $2, $25
3632; MM32-NEXT:    lw $1, %got(y)($2)
3633; MM32-NEXT:    addiu $2, $zero, -4
3634; MM32-NEXT:    and $2, $1, $2
3635; MM32-NEXT:    andi $1, $1, 3
3636; MM32-NEXT:    sll $3, $1, 3
3637; MM32-NEXT:    ori $1, $zero, 255
3638; MM32-NEXT:    sllv $5, $1, $3
3639; MM32-NEXT:    nor $6, $zero, $5
3640; MM32-NEXT:    sllv $4, $4, $3
3641; MM32-NEXT:  $BB10_1: # %entry
3642; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
3643; MM32-NEXT:    ll $7, 0($2)
3644; MM32-NEXT:    and $8, $7, $4
3645; MM32-NEXT:    nor $8, $zero, $8
3646; MM32-NEXT:    and $8, $8, $5
3647; MM32-NEXT:    and $9, $7, $6
3648; MM32-NEXT:    or $9, $9, $8
3649; MM32-NEXT:    sc $9, 0($2)
3650; MM32-NEXT:    beqzc $9, $BB10_1
3651; MM32-NEXT:  # %bb.2: # %entry
3652; MM32-NEXT:    and $1, $7, $5
3653; MM32-NEXT:    srlv $1, $1, $3
3654; MM32-NEXT:    seb $1, $1
3655; MM32-NEXT:  # %bb.3: # %entry
3656; MM32-NEXT:    jr $ra
3657; MM32-NEXT:    seb $2, $1
3658;
3659; O1-LABEL: AtomicLoadNand8:
3660; O1:       # %bb.0: # %entry
3661; O1-NEXT:    lui $2, %hi(_gp_disp)
3662; O1-NEXT:    addiu $2, $2, %lo(_gp_disp)
3663; O1-NEXT:    addu $1, $2, $25
3664; O1-NEXT:    lw $1, %got(y)($1)
3665; O1-NEXT:    addiu $2, $zero, -4
3666; O1-NEXT:    and $2, $1, $2
3667; O1-NEXT:    andi $1, $1, 3
3668; O1-NEXT:    sll $3, $1, 3
3669; O1-NEXT:    ori $1, $zero, 255
3670; O1-NEXT:    sllv $5, $1, $3
3671; O1-NEXT:    nor $6, $zero, $5
3672; O1-NEXT:    sllv $4, $4, $3
3673; O1-NEXT:  $BB10_1: # %entry
3674; O1-NEXT:    # =>This Inner Loop Header: Depth=1
3675; O1-NEXT:    ll $7, 0($2)
3676; O1-NEXT:    and $8, $7, $4
3677; O1-NEXT:    nor $8, $zero, $8
3678; O1-NEXT:    and $8, $8, $5
3679; O1-NEXT:    and $9, $7, $6
3680; O1-NEXT:    or $9, $9, $8
3681; O1-NEXT:    sc $9, 0($2)
3682; O1-NEXT:    beqz $9, $BB10_1
3683; O1-NEXT:    nop
3684; O1-NEXT:  # %bb.2: # %entry
3685; O1-NEXT:    and $1, $7, $5
3686; O1-NEXT:    srlv $1, $1, $3
3687; O1-NEXT:    sll $1, $1, 24
3688; O1-NEXT:    sra $1, $1, 24
3689; O1-NEXT:  # %bb.3: # %entry
3690; O1-NEXT:    sll $1, $1, 24
3691; O1-NEXT:    jr $ra
3692; O1-NEXT:    sra $2, $1, 24
3693;
3694; O2-LABEL: AtomicLoadNand8:
3695; O2:       # %bb.0: # %entry
3696; O2-NEXT:    lui $2, %hi(_gp_disp)
3697; O2-NEXT:    addiu $2, $2, %lo(_gp_disp)
3698; O2-NEXT:    addu $1, $2, $25
3699; O2-NEXT:    lw $1, %got(y)($1)
3700; O2-NEXT:    addiu $2, $zero, -4
3701; O2-NEXT:    and $2, $1, $2
3702; O2-NEXT:    andi $1, $1, 3
3703; O2-NEXT:    sll $3, $1, 3
3704; O2-NEXT:    ori $1, $zero, 255
3705; O2-NEXT:    sllv $5, $1, $3
3706; O2-NEXT:    nor $6, $zero, $5
3707; O2-NEXT:    sllv $4, $4, $3
3708; O2-NEXT:  $BB10_1: # %entry
3709; O2-NEXT:    # =>This Inner Loop Header: Depth=1
3710; O2-NEXT:    ll $7, 0($2)
3711; O2-NEXT:    and $8, $7, $4
3712; O2-NEXT:    nor $8, $zero, $8
3713; O2-NEXT:    and $8, $8, $5
3714; O2-NEXT:    and $9, $7, $6
3715; O2-NEXT:    or $9, $9, $8
3716; O2-NEXT:    sc $9, 0($2)
3717; O2-NEXT:    beqz $9, $BB10_1
3718; O2-NEXT:    nop
3719; O2-NEXT:  # %bb.2: # %entry
3720; O2-NEXT:    and $1, $7, $5
3721; O2-NEXT:    srlv $1, $1, $3
3722; O2-NEXT:    sll $1, $1, 24
3723; O2-NEXT:    sra $1, $1, 24
3724; O2-NEXT:  # %bb.3: # %entry
3725; O2-NEXT:    sll $1, $1, 24
3726; O2-NEXT:    jr $ra
3727; O2-NEXT:    sra $2, $1, 24
3728;
3729; O3-LABEL: AtomicLoadNand8:
3730; O3:       # %bb.0: # %entry
3731; O3-NEXT:    lui $2, %hi(_gp_disp)
3732; O3-NEXT:    addiu $2, $2, %lo(_gp_disp)
3733; O3-NEXT:    addu $1, $2, $25
3734; O3-NEXT:    addiu $2, $zero, -4
3735; O3-NEXT:    lw $1, %got(y)($1)
3736; O3-NEXT:    and $2, $1, $2
3737; O3-NEXT:    andi $1, $1, 3
3738; O3-NEXT:    sll $3, $1, 3
3739; O3-NEXT:    ori $1, $zero, 255
3740; O3-NEXT:    sllv $5, $1, $3
3741; O3-NEXT:    sllv $4, $4, $3
3742; O3-NEXT:    nor $6, $zero, $5
3743; O3-NEXT:  $BB10_1: # %entry
3744; O3-NEXT:    # =>This Inner Loop Header: Depth=1
3745; O3-NEXT:    ll $7, 0($2)
3746; O3-NEXT:    and $8, $7, $4
3747; O3-NEXT:    nor $8, $zero, $8
3748; O3-NEXT:    and $8, $8, $5
3749; O3-NEXT:    and $9, $7, $6
3750; O3-NEXT:    or $9, $9, $8
3751; O3-NEXT:    sc $9, 0($2)
3752; O3-NEXT:    beqz $9, $BB10_1
3753; O3-NEXT:    nop
3754; O3-NEXT:  # %bb.2: # %entry
3755; O3-NEXT:    and $1, $7, $5
3756; O3-NEXT:    srlv $1, $1, $3
3757; O3-NEXT:    sll $1, $1, 24
3758; O3-NEXT:    sra $1, $1, 24
3759; O3-NEXT:  # %bb.3: # %entry
3760; O3-NEXT:    sll $1, $1, 24
3761; O3-NEXT:    jr $ra
3762; O3-NEXT:    sra $2, $1, 24
3763;
3764; MIPS32EB-LABEL: AtomicLoadNand8:
3765; MIPS32EB:       # %bb.0: # %entry
3766; MIPS32EB-NEXT:    lui $2, %hi(_gp_disp)
3767; MIPS32EB-NEXT:    addiu $2, $2, %lo(_gp_disp)
3768; MIPS32EB-NEXT:    addu $1, $2, $25
3769; MIPS32EB-NEXT:    lw $1, %got(y)($1)
3770; MIPS32EB-NEXT:    addiu $2, $zero, -4
3771; MIPS32EB-NEXT:    and $2, $1, $2
3772; MIPS32EB-NEXT:    andi $1, $1, 3
3773; MIPS32EB-NEXT:    xori $1, $1, 3
3774; MIPS32EB-NEXT:    sll $3, $1, 3
3775; MIPS32EB-NEXT:    ori $1, $zero, 255
3776; MIPS32EB-NEXT:    sllv $5, $1, $3
3777; MIPS32EB-NEXT:    nor $6, $zero, $5
3778; MIPS32EB-NEXT:    sllv $4, $4, $3
3779; MIPS32EB-NEXT:  $BB10_1: # %entry
3780; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
3781; MIPS32EB-NEXT:    ll $7, 0($2)
3782; MIPS32EB-NEXT:    and $8, $7, $4
3783; MIPS32EB-NEXT:    nor $8, $zero, $8
3784; MIPS32EB-NEXT:    and $8, $8, $5
3785; MIPS32EB-NEXT:    and $9, $7, $6
3786; MIPS32EB-NEXT:    or $9, $9, $8
3787; MIPS32EB-NEXT:    sc $9, 0($2)
3788; MIPS32EB-NEXT:    beqz $9, $BB10_1
3789; MIPS32EB-NEXT:    nop
3790; MIPS32EB-NEXT:  # %bb.2: # %entry
3791; MIPS32EB-NEXT:    and $1, $7, $5
3792; MIPS32EB-NEXT:    srlv $1, $1, $3
3793; MIPS32EB-NEXT:    sll $1, $1, 24
3794; MIPS32EB-NEXT:    sra $1, $1, 24
3795; MIPS32EB-NEXT:  # %bb.3: # %entry
3796; MIPS32EB-NEXT:    sll $1, $1, 24
3797; MIPS32EB-NEXT:    jr $ra
3798; MIPS32EB-NEXT:    sra $2, $1, 24
3799entry:
3800  %0 = atomicrmw nand i8* @y, i8 %incr monotonic
3801  ret i8 %0
3802
3803}
3804
3805define signext i8 @AtomicSwap8(i8 signext %newval) nounwind {
3806; MIPS32-LABEL: AtomicSwap8:
3807; MIPS32:       # %bb.0: # %entry
3808; MIPS32-NEXT:    lui $2, %hi(_gp_disp)
3809; MIPS32-NEXT:    addiu $2, $2, %lo(_gp_disp)
3810; MIPS32-NEXT:    addu $1, $2, $25
3811; MIPS32-NEXT:    lw $1, %got(y)($1)
3812; MIPS32-NEXT:    addiu $2, $zero, -4
3813; MIPS32-NEXT:    and $2, $1, $2
3814; MIPS32-NEXT:    andi $1, $1, 3
3815; MIPS32-NEXT:    sll $3, $1, 3
3816; MIPS32-NEXT:    ori $1, $zero, 255
3817; MIPS32-NEXT:    sllv $5, $1, $3
3818; MIPS32-NEXT:    nor $6, $zero, $5
3819; MIPS32-NEXT:    sllv $4, $4, $3
3820; MIPS32-NEXT:  $BB11_1: # %entry
3821; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
3822; MIPS32-NEXT:    ll $7, 0($2)
3823; MIPS32-NEXT:    and $8, $4, $5
3824; MIPS32-NEXT:    and $9, $7, $6
3825; MIPS32-NEXT:    or $9, $9, $8
3826; MIPS32-NEXT:    sc $9, 0($2)
3827; MIPS32-NEXT:    beqz $9, $BB11_1
3828; MIPS32-NEXT:    nop
3829; MIPS32-NEXT:  # %bb.2: # %entry
3830; MIPS32-NEXT:    and $1, $7, $5
3831; MIPS32-NEXT:    srlv $1, $1, $3
3832; MIPS32-NEXT:    sll $1, $1, 24
3833; MIPS32-NEXT:    sra $1, $1, 24
3834; MIPS32-NEXT:  # %bb.3: # %entry
3835; MIPS32-NEXT:    sll $1, $1, 24
3836; MIPS32-NEXT:    jr $ra
3837; MIPS32-NEXT:    sra $2, $1, 24
3838;
3839; MIPS32O0-LABEL: AtomicSwap8:
3840; MIPS32O0:       # %bb.0: # %entry
3841; MIPS32O0-NEXT:    lui $2, %hi(_gp_disp)
3842; MIPS32O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
3843; MIPS32O0-NEXT:    addiu $sp, $sp, -8
3844; MIPS32O0-NEXT:    addu $1, $2, $25
3845; MIPS32O0-NEXT:    lw $1, %got(y)($1)
3846; MIPS32O0-NEXT:    addiu $2, $zero, -4
3847; MIPS32O0-NEXT:    and $5, $1, $2
3848; MIPS32O0-NEXT:    andi $1, $1, 3
3849; MIPS32O0-NEXT:    sll $9, $1, 3
3850; MIPS32O0-NEXT:    ori $1, $zero, 255
3851; MIPS32O0-NEXT:    sllv $7, $1, $9
3852; MIPS32O0-NEXT:    nor $8, $zero, $7
3853; MIPS32O0-NEXT:    sllv $6, $4, $9
3854; MIPS32O0-NEXT:  $BB11_1: # %entry
3855; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
3856; MIPS32O0-NEXT:    ll $2, 0($5)
3857; MIPS32O0-NEXT:    and $3, $6, $7
3858; MIPS32O0-NEXT:    and $4, $2, $8
3859; MIPS32O0-NEXT:    or $4, $4, $3
3860; MIPS32O0-NEXT:    sc $4, 0($5)
3861; MIPS32O0-NEXT:    beqz $4, $BB11_1
3862; MIPS32O0-NEXT:    nop
3863; MIPS32O0-NEXT:  # %bb.2: # %entry
3864; MIPS32O0-NEXT:    and $1, $2, $7
3865; MIPS32O0-NEXT:    srlv $1, $1, $9
3866; MIPS32O0-NEXT:    sll $1, $1, 24
3867; MIPS32O0-NEXT:    sra $1, $1, 24
3868; MIPS32O0-NEXT:  # %bb.3: # %entry
3869; MIPS32O0-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3870; MIPS32O0-NEXT:  # %bb.4: # %entry
3871; MIPS32O0-NEXT:    lw $1, 4($sp) # 4-byte Folded Reload
3872; MIPS32O0-NEXT:    sll $1, $1, 24
3873; MIPS32O0-NEXT:    sra $2, $1, 24
3874; MIPS32O0-NEXT:    addiu $sp, $sp, 8
3875; MIPS32O0-NEXT:    jr $ra
3876; MIPS32O0-NEXT:    nop
3877;
3878; MIPS32R2-LABEL: AtomicSwap8:
3879; MIPS32R2:       # %bb.0: # %entry
3880; MIPS32R2-NEXT:    lui $2, %hi(_gp_disp)
3881; MIPS32R2-NEXT:    addiu $2, $2, %lo(_gp_disp)
3882; MIPS32R2-NEXT:    addu $1, $2, $25
3883; MIPS32R2-NEXT:    lw $1, %got(y)($1)
3884; MIPS32R2-NEXT:    addiu $2, $zero, -4
3885; MIPS32R2-NEXT:    and $2, $1, $2
3886; MIPS32R2-NEXT:    andi $1, $1, 3
3887; MIPS32R2-NEXT:    sll $3, $1, 3
3888; MIPS32R2-NEXT:    ori $1, $zero, 255
3889; MIPS32R2-NEXT:    sllv $5, $1, $3
3890; MIPS32R2-NEXT:    nor $6, $zero, $5
3891; MIPS32R2-NEXT:    sllv $4, $4, $3
3892; MIPS32R2-NEXT:  $BB11_1: # %entry
3893; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
3894; MIPS32R2-NEXT:    ll $7, 0($2)
3895; MIPS32R2-NEXT:    and $8, $4, $5
3896; MIPS32R2-NEXT:    and $9, $7, $6
3897; MIPS32R2-NEXT:    or $9, $9, $8
3898; MIPS32R2-NEXT:    sc $9, 0($2)
3899; MIPS32R2-NEXT:    beqz $9, $BB11_1
3900; MIPS32R2-NEXT:    nop
3901; MIPS32R2-NEXT:  # %bb.2: # %entry
3902; MIPS32R2-NEXT:    and $1, $7, $5
3903; MIPS32R2-NEXT:    srlv $1, $1, $3
3904; MIPS32R2-NEXT:    seb $1, $1
3905; MIPS32R2-NEXT:  # %bb.3: # %entry
3906; MIPS32R2-NEXT:    jr $ra
3907; MIPS32R2-NEXT:    seb $2, $1
3908;
3909; MIPS32R6-LABEL: AtomicSwap8:
3910; MIPS32R6:       # %bb.0: # %entry
3911; MIPS32R6-NEXT:    lui $2, %hi(_gp_disp)
3912; MIPS32R6-NEXT:    addiu $2, $2, %lo(_gp_disp)
3913; MIPS32R6-NEXT:    addu $1, $2, $25
3914; MIPS32R6-NEXT:    lw $1, %got(y)($1)
3915; MIPS32R6-NEXT:    addiu $2, $zero, -4
3916; MIPS32R6-NEXT:    and $2, $1, $2
3917; MIPS32R6-NEXT:    andi $1, $1, 3
3918; MIPS32R6-NEXT:    sll $3, $1, 3
3919; MIPS32R6-NEXT:    ori $1, $zero, 255
3920; MIPS32R6-NEXT:    sllv $5, $1, $3
3921; MIPS32R6-NEXT:    nor $6, $zero, $5
3922; MIPS32R6-NEXT:    sllv $4, $4, $3
3923; MIPS32R6-NEXT:  $BB11_1: # %entry
3924; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
3925; MIPS32R6-NEXT:    ll $7, 0($2)
3926; MIPS32R6-NEXT:    and $8, $4, $5
3927; MIPS32R6-NEXT:    and $9, $7, $6
3928; MIPS32R6-NEXT:    or $9, $9, $8
3929; MIPS32R6-NEXT:    sc $9, 0($2)
3930; MIPS32R6-NEXT:    beqzc $9, $BB11_1
3931; MIPS32R6-NEXT:  # %bb.2: # %entry
3932; MIPS32R6-NEXT:    and $1, $7, $5
3933; MIPS32R6-NEXT:    srlv $1, $1, $3
3934; MIPS32R6-NEXT:    seb $1, $1
3935; MIPS32R6-NEXT:  # %bb.3: # %entry
3936; MIPS32R6-NEXT:    jr $ra
3937; MIPS32R6-NEXT:    seb $2, $1
3938;
3939; MIPS32R6O0-LABEL: AtomicSwap8:
3940; MIPS32R6O0:       # %bb.0: # %entry
3941; MIPS32R6O0-NEXT:    lui $2, %hi(_gp_disp)
3942; MIPS32R6O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
3943; MIPS32R6O0-NEXT:    addiu $sp, $sp, -8
3944; MIPS32R6O0-NEXT:    addu $1, $2, $25
3945; MIPS32R6O0-NEXT:    # kill: def $v0 killed $a0
3946; MIPS32R6O0-NEXT:    lw $1, %got(y)($1)
3947; MIPS32R6O0-NEXT:    addiu $2, $zero, -4
3948; MIPS32R6O0-NEXT:    and $5, $1, $2
3949; MIPS32R6O0-NEXT:    andi $1, $1, 3
3950; MIPS32R6O0-NEXT:    sll $9, $1, 3
3951; MIPS32R6O0-NEXT:    ori $1, $zero, 255
3952; MIPS32R6O0-NEXT:    sllv $7, $1, $9
3953; MIPS32R6O0-NEXT:    nor $8, $zero, $7
3954; MIPS32R6O0-NEXT:    sllv $6, $4, $9
3955; MIPS32R6O0-NEXT:  $BB11_1: # %entry
3956; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
3957; MIPS32R6O0-NEXT:    ll $2, 0($5)
3958; MIPS32R6O0-NEXT:    and $3, $6, $7
3959; MIPS32R6O0-NEXT:    and $4, $2, $8
3960; MIPS32R6O0-NEXT:    or $4, $4, $3
3961; MIPS32R6O0-NEXT:    sc $4, 0($5)
3962; MIPS32R6O0-NEXT:    beqzc $4, $BB11_1
3963; MIPS32R6O0-NEXT:  # %bb.2: # %entry
3964; MIPS32R6O0-NEXT:    and $1, $2, $7
3965; MIPS32R6O0-NEXT:    srlv $1, $1, $9
3966; MIPS32R6O0-NEXT:    seb $1, $1
3967; MIPS32R6O0-NEXT:  # %bb.3: # %entry
3968; MIPS32R6O0-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3969; MIPS32R6O0-NEXT:  # %bb.4: # %entry
3970; MIPS32R6O0-NEXT:    lw $1, 4($sp) # 4-byte Folded Reload
3971; MIPS32R6O0-NEXT:    seb $2, $1
3972; MIPS32R6O0-NEXT:    addiu $sp, $sp, 8
3973; MIPS32R6O0-NEXT:    jrc $ra
3974;
3975; MIPS4-LABEL: AtomicSwap8:
3976; MIPS4:       # %bb.0: # %entry
3977; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap8)))
3978; MIPS4-NEXT:    daddu $1, $1, $25
3979; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap8)))
3980; MIPS4-NEXT:    ld $1, %got_disp(y)($1)
3981; MIPS4-NEXT:    daddiu $2, $zero, -4
3982; MIPS4-NEXT:    and $2, $1, $2
3983; MIPS4-NEXT:    andi $1, $1, 3
3984; MIPS4-NEXT:    sll $3, $1, 3
3985; MIPS4-NEXT:    ori $1, $zero, 255
3986; MIPS4-NEXT:    sllv $5, $1, $3
3987; MIPS4-NEXT:    nor $6, $zero, $5
3988; MIPS4-NEXT:    sllv $4, $4, $3
3989; MIPS4-NEXT:  .LBB11_1: # %entry
3990; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
3991; MIPS4-NEXT:    ll $7, 0($2)
3992; MIPS4-NEXT:    and $8, $4, $5
3993; MIPS4-NEXT:    and $9, $7, $6
3994; MIPS4-NEXT:    or $9, $9, $8
3995; MIPS4-NEXT:    sc $9, 0($2)
3996; MIPS4-NEXT:    beqz $9, .LBB11_1
3997; MIPS4-NEXT:    nop
3998; MIPS4-NEXT:  # %bb.2: # %entry
3999; MIPS4-NEXT:    and $1, $7, $5
4000; MIPS4-NEXT:    srlv $1, $1, $3
4001; MIPS4-NEXT:    sll $1, $1, 24
4002; MIPS4-NEXT:    sra $1, $1, 24
4003; MIPS4-NEXT:  # %bb.3: # %entry
4004; MIPS4-NEXT:    sll $1, $1, 24
4005; MIPS4-NEXT:    jr $ra
4006; MIPS4-NEXT:    sra $2, $1, 24
4007;
4008; MIPS64-LABEL: AtomicSwap8:
4009; MIPS64:       # %bb.0: # %entry
4010; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap8)))
4011; MIPS64-NEXT:    daddu $1, $1, $25
4012; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap8)))
4013; MIPS64-NEXT:    ld $1, %got_disp(y)($1)
4014; MIPS64-NEXT:    daddiu $2, $zero, -4
4015; MIPS64-NEXT:    and $2, $1, $2
4016; MIPS64-NEXT:    andi $1, $1, 3
4017; MIPS64-NEXT:    sll $3, $1, 3
4018; MIPS64-NEXT:    ori $1, $zero, 255
4019; MIPS64-NEXT:    sllv $5, $1, $3
4020; MIPS64-NEXT:    nor $6, $zero, $5
4021; MIPS64-NEXT:    sllv $4, $4, $3
4022; MIPS64-NEXT:  .LBB11_1: # %entry
4023; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
4024; MIPS64-NEXT:    ll $7, 0($2)
4025; MIPS64-NEXT:    and $8, $4, $5
4026; MIPS64-NEXT:    and $9, $7, $6
4027; MIPS64-NEXT:    or $9, $9, $8
4028; MIPS64-NEXT:    sc $9, 0($2)
4029; MIPS64-NEXT:    beqz $9, .LBB11_1
4030; MIPS64-NEXT:    nop
4031; MIPS64-NEXT:  # %bb.2: # %entry
4032; MIPS64-NEXT:    and $1, $7, $5
4033; MIPS64-NEXT:    srlv $1, $1, $3
4034; MIPS64-NEXT:    sll $1, $1, 24
4035; MIPS64-NEXT:    sra $1, $1, 24
4036; MIPS64-NEXT:  # %bb.3: # %entry
4037; MIPS64-NEXT:    sll $1, $1, 24
4038; MIPS64-NEXT:    jr $ra
4039; MIPS64-NEXT:    sra $2, $1, 24
4040;
4041; MIPS64R2-LABEL: AtomicSwap8:
4042; MIPS64R2:       # %bb.0: # %entry
4043; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap8)))
4044; MIPS64R2-NEXT:    daddu $1, $1, $25
4045; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap8)))
4046; MIPS64R2-NEXT:    ld $1, %got_disp(y)($1)
4047; MIPS64R2-NEXT:    daddiu $2, $zero, -4
4048; MIPS64R2-NEXT:    and $2, $1, $2
4049; MIPS64R2-NEXT:    andi $1, $1, 3
4050; MIPS64R2-NEXT:    sll $3, $1, 3
4051; MIPS64R2-NEXT:    ori $1, $zero, 255
4052; MIPS64R2-NEXT:    sllv $5, $1, $3
4053; MIPS64R2-NEXT:    nor $6, $zero, $5
4054; MIPS64R2-NEXT:    sllv $4, $4, $3
4055; MIPS64R2-NEXT:  .LBB11_1: # %entry
4056; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
4057; MIPS64R2-NEXT:    ll $7, 0($2)
4058; MIPS64R2-NEXT:    and $8, $4, $5
4059; MIPS64R2-NEXT:    and $9, $7, $6
4060; MIPS64R2-NEXT:    or $9, $9, $8
4061; MIPS64R2-NEXT:    sc $9, 0($2)
4062; MIPS64R2-NEXT:    beqz $9, .LBB11_1
4063; MIPS64R2-NEXT:    nop
4064; MIPS64R2-NEXT:  # %bb.2: # %entry
4065; MIPS64R2-NEXT:    and $1, $7, $5
4066; MIPS64R2-NEXT:    srlv $1, $1, $3
4067; MIPS64R2-NEXT:    seb $1, $1
4068; MIPS64R2-NEXT:  # %bb.3: # %entry
4069; MIPS64R2-NEXT:    jr $ra
4070; MIPS64R2-NEXT:    seb $2, $1
4071;
4072; MIPS64R6-LABEL: AtomicSwap8:
4073; MIPS64R6:       # %bb.0: # %entry
4074; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap8)))
4075; MIPS64R6-NEXT:    daddu $1, $1, $25
4076; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicSwap8)))
4077; MIPS64R6-NEXT:    ld $1, %got_disp(y)($1)
4078; MIPS64R6-NEXT:    daddiu $2, $zero, -4
4079; MIPS64R6-NEXT:    and $2, $1, $2
4080; MIPS64R6-NEXT:    andi $1, $1, 3
4081; MIPS64R6-NEXT:    sll $3, $1, 3
4082; MIPS64R6-NEXT:    ori $1, $zero, 255
4083; MIPS64R6-NEXT:    sllv $5, $1, $3
4084; MIPS64R6-NEXT:    nor $6, $zero, $5
4085; MIPS64R6-NEXT:    sllv $4, $4, $3
4086; MIPS64R6-NEXT:  .LBB11_1: # %entry
4087; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
4088; MIPS64R6-NEXT:    ll $7, 0($2)
4089; MIPS64R6-NEXT:    and $8, $4, $5
4090; MIPS64R6-NEXT:    and $9, $7, $6
4091; MIPS64R6-NEXT:    or $9, $9, $8
4092; MIPS64R6-NEXT:    sc $9, 0($2)
4093; MIPS64R6-NEXT:    beqzc $9, .LBB11_1
4094; MIPS64R6-NEXT:  # %bb.2: # %entry
4095; MIPS64R6-NEXT:    and $1, $7, $5
4096; MIPS64R6-NEXT:    srlv $1, $1, $3
4097; MIPS64R6-NEXT:    seb $1, $1
4098; MIPS64R6-NEXT:  # %bb.3: # %entry
4099; MIPS64R6-NEXT:    jr $ra
4100; MIPS64R6-NEXT:    seb $2, $1
4101;
4102; MIPS64R6O0-LABEL: AtomicSwap8:
4103; MIPS64R6O0:       # %bb.0: # %entry
4104; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -16
4105; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicSwap8)))
4106; MIPS64R6O0-NEXT:    daddu $1, $1, $25
4107; MIPS64R6O0-NEXT:    daddiu $2, $1, %lo(%neg(%gp_rel(AtomicSwap8)))
4108; MIPS64R6O0-NEXT:    move $1, $4
4109; MIPS64R6O0-NEXT:    ld $2, %got_disp(y)($2)
4110; MIPS64R6O0-NEXT:    daddiu $3, $zero, -4
4111; MIPS64R6O0-NEXT:    and $5, $2, $3
4112; MIPS64R6O0-NEXT:    andi $2, $2, 3
4113; MIPS64R6O0-NEXT:    xori $2, $2, 3
4114; MIPS64R6O0-NEXT:    sll $9, $2, 3
4115; MIPS64R6O0-NEXT:    ori $2, $zero, 255
4116; MIPS64R6O0-NEXT:    sllv $7, $2, $9
4117; MIPS64R6O0-NEXT:    nor $8, $zero, $7
4118; MIPS64R6O0-NEXT:    sllv $6, $1, $9
4119; MIPS64R6O0-NEXT:  .LBB11_1: # %entry
4120; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
4121; MIPS64R6O0-NEXT:    ll $2, 0($5)
4122; MIPS64R6O0-NEXT:    and $3, $6, $7
4123; MIPS64R6O0-NEXT:    and $4, $2, $8
4124; MIPS64R6O0-NEXT:    or $4, $4, $3
4125; MIPS64R6O0-NEXT:    sc $4, 0($5)
4126; MIPS64R6O0-NEXT:    beqzc $4, .LBB11_1
4127; MIPS64R6O0-NEXT:  # %bb.2: # %entry
4128; MIPS64R6O0-NEXT:    and $1, $2, $7
4129; MIPS64R6O0-NEXT:    srlv $1, $1, $9
4130; MIPS64R6O0-NEXT:    seb $1, $1
4131; MIPS64R6O0-NEXT:  # %bb.3: # %entry
4132; MIPS64R6O0-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
4133; MIPS64R6O0-NEXT:  # %bb.4: # %entry
4134; MIPS64R6O0-NEXT:    lw $1, 12($sp) # 4-byte Folded Reload
4135; MIPS64R6O0-NEXT:    seb $2, $1
4136; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 16
4137; MIPS64R6O0-NEXT:    jrc $ra
4138;
4139; MM32-LABEL: AtomicSwap8:
4140; MM32:       # %bb.0: # %entry
4141; MM32-NEXT:    lui $2, %hi(_gp_disp)
4142; MM32-NEXT:    addiu $2, $2, %lo(_gp_disp)
4143; MM32-NEXT:    addu $2, $2, $25
4144; MM32-NEXT:    lw $1, %got(y)($2)
4145; MM32-NEXT:    addiu $2, $zero, -4
4146; MM32-NEXT:    and $2, $1, $2
4147; MM32-NEXT:    andi $1, $1, 3
4148; MM32-NEXT:    sll $3, $1, 3
4149; MM32-NEXT:    ori $1, $zero, 255
4150; MM32-NEXT:    sllv $5, $1, $3
4151; MM32-NEXT:    nor $6, $zero, $5
4152; MM32-NEXT:    sllv $4, $4, $3
4153; MM32-NEXT:  $BB11_1: # %entry
4154; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
4155; MM32-NEXT:    ll $7, 0($2)
4156; MM32-NEXT:    and $8, $4, $5
4157; MM32-NEXT:    and $9, $7, $6
4158; MM32-NEXT:    or $9, $9, $8
4159; MM32-NEXT:    sc $9, 0($2)
4160; MM32-NEXT:    beqzc $9, $BB11_1
4161; MM32-NEXT:  # %bb.2: # %entry
4162; MM32-NEXT:    and $1, $7, $5
4163; MM32-NEXT:    srlv $1, $1, $3
4164; MM32-NEXT:    seb $1, $1
4165; MM32-NEXT:  # %bb.3: # %entry
4166; MM32-NEXT:    jr $ra
4167; MM32-NEXT:    seb $2, $1
4168;
4169; O1-LABEL: AtomicSwap8:
4170; O1:       # %bb.0: # %entry
4171; O1-NEXT:    lui $2, %hi(_gp_disp)
4172; O1-NEXT:    addiu $2, $2, %lo(_gp_disp)
4173; O1-NEXT:    addu $1, $2, $25
4174; O1-NEXT:    lw $1, %got(y)($1)
4175; O1-NEXT:    addiu $2, $zero, -4
4176; O1-NEXT:    and $2, $1, $2
4177; O1-NEXT:    andi $1, $1, 3
4178; O1-NEXT:    sll $3, $1, 3
4179; O1-NEXT:    ori $1, $zero, 255
4180; O1-NEXT:    sllv $5, $1, $3
4181; O1-NEXT:    nor $6, $zero, $5
4182; O1-NEXT:    sllv $4, $4, $3
4183; O1-NEXT:  $BB11_1: # %entry
4184; O1-NEXT:    # =>This Inner Loop Header: Depth=1
4185; O1-NEXT:    ll $7, 0($2)
4186; O1-NEXT:    and $8, $4, $5
4187; O1-NEXT:    and $9, $7, $6
4188; O1-NEXT:    or $9, $9, $8
4189; O1-NEXT:    sc $9, 0($2)
4190; O1-NEXT:    beqz $9, $BB11_1
4191; O1-NEXT:    nop
4192; O1-NEXT:  # %bb.2: # %entry
4193; O1-NEXT:    and $1, $7, $5
4194; O1-NEXT:    srlv $1, $1, $3
4195; O1-NEXT:    sll $1, $1, 24
4196; O1-NEXT:    sra $1, $1, 24
4197; O1-NEXT:  # %bb.3: # %entry
4198; O1-NEXT:    sll $1, $1, 24
4199; O1-NEXT:    jr $ra
4200; O1-NEXT:    sra $2, $1, 24
4201;
4202; O2-LABEL: AtomicSwap8:
4203; O2:       # %bb.0: # %entry
4204; O2-NEXT:    lui $2, %hi(_gp_disp)
4205; O2-NEXT:    addiu $2, $2, %lo(_gp_disp)
4206; O2-NEXT:    addu $1, $2, $25
4207; O2-NEXT:    lw $1, %got(y)($1)
4208; O2-NEXT:    addiu $2, $zero, -4
4209; O2-NEXT:    and $2, $1, $2
4210; O2-NEXT:    andi $1, $1, 3
4211; O2-NEXT:    sll $3, $1, 3
4212; O2-NEXT:    ori $1, $zero, 255
4213; O2-NEXT:    sllv $5, $1, $3
4214; O2-NEXT:    nor $6, $zero, $5
4215; O2-NEXT:    sllv $4, $4, $3
4216; O2-NEXT:  $BB11_1: # %entry
4217; O2-NEXT:    # =>This Inner Loop Header: Depth=1
4218; O2-NEXT:    ll $7, 0($2)
4219; O2-NEXT:    and $8, $4, $5
4220; O2-NEXT:    and $9, $7, $6
4221; O2-NEXT:    or $9, $9, $8
4222; O2-NEXT:    sc $9, 0($2)
4223; O2-NEXT:    beqz $9, $BB11_1
4224; O2-NEXT:    nop
4225; O2-NEXT:  # %bb.2: # %entry
4226; O2-NEXT:    and $1, $7, $5
4227; O2-NEXT:    srlv $1, $1, $3
4228; O2-NEXT:    sll $1, $1, 24
4229; O2-NEXT:    sra $1, $1, 24
4230; O2-NEXT:  # %bb.3: # %entry
4231; O2-NEXT:    sll $1, $1, 24
4232; O2-NEXT:    jr $ra
4233; O2-NEXT:    sra $2, $1, 24
4234;
4235; O3-LABEL: AtomicSwap8:
4236; O3:       # %bb.0: # %entry
4237; O3-NEXT:    lui $2, %hi(_gp_disp)
4238; O3-NEXT:    addiu $2, $2, %lo(_gp_disp)
4239; O3-NEXT:    addu $1, $2, $25
4240; O3-NEXT:    addiu $2, $zero, -4
4241; O3-NEXT:    lw $1, %got(y)($1)
4242; O3-NEXT:    and $2, $1, $2
4243; O3-NEXT:    andi $1, $1, 3
4244; O3-NEXT:    sll $3, $1, 3
4245; O3-NEXT:    ori $1, $zero, 255
4246; O3-NEXT:    sllv $5, $1, $3
4247; O3-NEXT:    sllv $4, $4, $3
4248; O3-NEXT:    nor $6, $zero, $5
4249; O3-NEXT:  $BB11_1: # %entry
4250; O3-NEXT:    # =>This Inner Loop Header: Depth=1
4251; O3-NEXT:    ll $7, 0($2)
4252; O3-NEXT:    and $8, $4, $5
4253; O3-NEXT:    and $9, $7, $6
4254; O3-NEXT:    or $9, $9, $8
4255; O3-NEXT:    sc $9, 0($2)
4256; O3-NEXT:    beqz $9, $BB11_1
4257; O3-NEXT:    nop
4258; O3-NEXT:  # %bb.2: # %entry
4259; O3-NEXT:    and $1, $7, $5
4260; O3-NEXT:    srlv $1, $1, $3
4261; O3-NEXT:    sll $1, $1, 24
4262; O3-NEXT:    sra $1, $1, 24
4263; O3-NEXT:  # %bb.3: # %entry
4264; O3-NEXT:    sll $1, $1, 24
4265; O3-NEXT:    jr $ra
4266; O3-NEXT:    sra $2, $1, 24
4267;
4268; MIPS32EB-LABEL: AtomicSwap8:
4269; MIPS32EB:       # %bb.0: # %entry
4270; MIPS32EB-NEXT:    lui $2, %hi(_gp_disp)
4271; MIPS32EB-NEXT:    addiu $2, $2, %lo(_gp_disp)
4272; MIPS32EB-NEXT:    addu $1, $2, $25
4273; MIPS32EB-NEXT:    lw $1, %got(y)($1)
4274; MIPS32EB-NEXT:    addiu $2, $zero, -4
4275; MIPS32EB-NEXT:    and $2, $1, $2
4276; MIPS32EB-NEXT:    andi $1, $1, 3
4277; MIPS32EB-NEXT:    xori $1, $1, 3
4278; MIPS32EB-NEXT:    sll $3, $1, 3
4279; MIPS32EB-NEXT:    ori $1, $zero, 255
4280; MIPS32EB-NEXT:    sllv $5, $1, $3
4281; MIPS32EB-NEXT:    nor $6, $zero, $5
4282; MIPS32EB-NEXT:    sllv $4, $4, $3
4283; MIPS32EB-NEXT:  $BB11_1: # %entry
4284; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
4285; MIPS32EB-NEXT:    ll $7, 0($2)
4286; MIPS32EB-NEXT:    and $8, $4, $5
4287; MIPS32EB-NEXT:    and $9, $7, $6
4288; MIPS32EB-NEXT:    or $9, $9, $8
4289; MIPS32EB-NEXT:    sc $9, 0($2)
4290; MIPS32EB-NEXT:    beqz $9, $BB11_1
4291; MIPS32EB-NEXT:    nop
4292; MIPS32EB-NEXT:  # %bb.2: # %entry
4293; MIPS32EB-NEXT:    and $1, $7, $5
4294; MIPS32EB-NEXT:    srlv $1, $1, $3
4295; MIPS32EB-NEXT:    sll $1, $1, 24
4296; MIPS32EB-NEXT:    sra $1, $1, 24
4297; MIPS32EB-NEXT:  # %bb.3: # %entry
4298; MIPS32EB-NEXT:    sll $1, $1, 24
4299; MIPS32EB-NEXT:    jr $ra
4300; MIPS32EB-NEXT:    sra $2, $1, 24
4301entry:
4302  %0 = atomicrmw xchg i8* @y, i8 %newval monotonic
4303  ret i8 %0
4304}
4305
4306define signext i8 @AtomicCmpSwap8(i8 signext %oldval, i8 signext %newval) nounwind {
4307; MIPS32-LABEL: AtomicCmpSwap8:
4308; MIPS32:       # %bb.0: # %entry
4309; MIPS32-NEXT:    lui $2, %hi(_gp_disp)
4310; MIPS32-NEXT:    addiu $2, $2, %lo(_gp_disp)
4311; MIPS32-NEXT:    addu $1, $2, $25
4312; MIPS32-NEXT:    lw $1, %got(y)($1)
4313; MIPS32-NEXT:    addiu $2, $zero, -4
4314; MIPS32-NEXT:    and $2, $1, $2
4315; MIPS32-NEXT:    andi $1, $1, 3
4316; MIPS32-NEXT:    sll $3, $1, 3
4317; MIPS32-NEXT:    ori $1, $zero, 255
4318; MIPS32-NEXT:    sllv $6, $1, $3
4319; MIPS32-NEXT:    nor $7, $zero, $6
4320; MIPS32-NEXT:    andi $1, $4, 255
4321; MIPS32-NEXT:    sllv $4, $1, $3
4322; MIPS32-NEXT:    andi $1, $5, 255
4323; MIPS32-NEXT:    sllv $5, $1, $3
4324; MIPS32-NEXT:  $BB12_1: # %entry
4325; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
4326; MIPS32-NEXT:    ll $8, 0($2)
4327; MIPS32-NEXT:    and $9, $8, $6
4328; MIPS32-NEXT:    bne $9, $4, $BB12_3
4329; MIPS32-NEXT:    nop
4330; MIPS32-NEXT:  # %bb.2: # %entry
4331; MIPS32-NEXT:    # in Loop: Header=BB12_1 Depth=1
4332; MIPS32-NEXT:    and $8, $8, $7
4333; MIPS32-NEXT:    or $8, $8, $5
4334; MIPS32-NEXT:    sc $8, 0($2)
4335; MIPS32-NEXT:    beqz $8, $BB12_1
4336; MIPS32-NEXT:    nop
4337; MIPS32-NEXT:  $BB12_3: # %entry
4338; MIPS32-NEXT:    srlv $1, $9, $3
4339; MIPS32-NEXT:    sll $1, $1, 24
4340; MIPS32-NEXT:    sra $1, $1, 24
4341; MIPS32-NEXT:  # %bb.4: # %entry
4342; MIPS32-NEXT:    sll $1, $1, 24
4343; MIPS32-NEXT:    jr $ra
4344; MIPS32-NEXT:    sra $2, $1, 24
4345;
4346; MIPS32O0-LABEL: AtomicCmpSwap8:
4347; MIPS32O0:       # %bb.0: # %entry
4348; MIPS32O0-NEXT:    lui $2, %hi(_gp_disp)
4349; MIPS32O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
4350; MIPS32O0-NEXT:    addiu $sp, $sp, -8
4351; MIPS32O0-NEXT:    addu $3, $2, $25
4352; MIPS32O0-NEXT:    move $1, $5
4353; MIPS32O0-NEXT:    move $2, $4
4354; MIPS32O0-NEXT:    lw $3, %got(y)($3)
4355; MIPS32O0-NEXT:    addiu $4, $zero, -4
4356; MIPS32O0-NEXT:    and $4, $3, $4
4357; MIPS32O0-NEXT:    andi $3, $3, 3
4358; MIPS32O0-NEXT:    sll $9, $3, 3
4359; MIPS32O0-NEXT:    ori $3, $zero, 255
4360; MIPS32O0-NEXT:    sllv $5, $3, $9
4361; MIPS32O0-NEXT:    nor $7, $zero, $5
4362; MIPS32O0-NEXT:    andi $2, $2, 255
4363; MIPS32O0-NEXT:    sllv $6, $2, $9
4364; MIPS32O0-NEXT:    andi $1, $1, 255
4365; MIPS32O0-NEXT:    sllv $8, $1, $9
4366; MIPS32O0-NEXT:  $BB12_1: # %entry
4367; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
4368; MIPS32O0-NEXT:    ll $2, 0($4)
4369; MIPS32O0-NEXT:    and $3, $2, $5
4370; MIPS32O0-NEXT:    bne $3, $6, $BB12_3
4371; MIPS32O0-NEXT:    nop
4372; MIPS32O0-NEXT:  # %bb.2: # %entry
4373; MIPS32O0-NEXT:    # in Loop: Header=BB12_1 Depth=1
4374; MIPS32O0-NEXT:    and $2, $2, $7
4375; MIPS32O0-NEXT:    or $2, $2, $8
4376; MIPS32O0-NEXT:    sc $2, 0($4)
4377; MIPS32O0-NEXT:    beqz $2, $BB12_1
4378; MIPS32O0-NEXT:    nop
4379; MIPS32O0-NEXT:  $BB12_3: # %entry
4380; MIPS32O0-NEXT:    srlv $1, $3, $9
4381; MIPS32O0-NEXT:    sll $1, $1, 24
4382; MIPS32O0-NEXT:    sra $1, $1, 24
4383; MIPS32O0-NEXT:  # %bb.4: # %entry
4384; MIPS32O0-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
4385; MIPS32O0-NEXT:  # %bb.5: # %entry
4386; MIPS32O0-NEXT:    lw $1, 4($sp) # 4-byte Folded Reload
4387; MIPS32O0-NEXT:    sll $1, $1, 24
4388; MIPS32O0-NEXT:    sra $2, $1, 24
4389; MIPS32O0-NEXT:    addiu $sp, $sp, 8
4390; MIPS32O0-NEXT:    jr $ra
4391; MIPS32O0-NEXT:    nop
4392;
4393; MIPS32R2-LABEL: AtomicCmpSwap8:
4394; MIPS32R2:       # %bb.0: # %entry
4395; MIPS32R2-NEXT:    lui $2, %hi(_gp_disp)
4396; MIPS32R2-NEXT:    addiu $2, $2, %lo(_gp_disp)
4397; MIPS32R2-NEXT:    addu $1, $2, $25
4398; MIPS32R2-NEXT:    lw $1, %got(y)($1)
4399; MIPS32R2-NEXT:    addiu $2, $zero, -4
4400; MIPS32R2-NEXT:    and $3, $1, $2
4401; MIPS32R2-NEXT:    andi $1, $1, 3
4402; MIPS32R2-NEXT:    sll $1, $1, 3
4403; MIPS32R2-NEXT:    ori $2, $zero, 255
4404; MIPS32R2-NEXT:    sllv $6, $2, $1
4405; MIPS32R2-NEXT:    nor $7, $zero, $6
4406; MIPS32R2-NEXT:    andi $2, $4, 255
4407; MIPS32R2-NEXT:    sllv $4, $2, $1
4408; MIPS32R2-NEXT:    andi $2, $5, 255
4409; MIPS32R2-NEXT:    sllv $5, $2, $1
4410; MIPS32R2-NEXT:  $BB12_1: # %entry
4411; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
4412; MIPS32R2-NEXT:    ll $8, 0($3)
4413; MIPS32R2-NEXT:    and $9, $8, $6
4414; MIPS32R2-NEXT:    bne $9, $4, $BB12_3
4415; MIPS32R2-NEXT:    nop
4416; MIPS32R2-NEXT:  # %bb.2: # %entry
4417; MIPS32R2-NEXT:    # in Loop: Header=BB12_1 Depth=1
4418; MIPS32R2-NEXT:    and $8, $8, $7
4419; MIPS32R2-NEXT:    or $8, $8, $5
4420; MIPS32R2-NEXT:    sc $8, 0($3)
4421; MIPS32R2-NEXT:    beqz $8, $BB12_1
4422; MIPS32R2-NEXT:    nop
4423; MIPS32R2-NEXT:  $BB12_3: # %entry
4424; MIPS32R2-NEXT:    srlv $2, $9, $1
4425; MIPS32R2-NEXT:    seb $2, $2
4426; MIPS32R2-NEXT:  # %bb.4: # %entry
4427; MIPS32R2-NEXT:    jr $ra
4428; MIPS32R2-NEXT:    nop
4429;
4430; MIPS32R6-LABEL: AtomicCmpSwap8:
4431; MIPS32R6:       # %bb.0: # %entry
4432; MIPS32R6-NEXT:    lui $2, %hi(_gp_disp)
4433; MIPS32R6-NEXT:    addiu $2, $2, %lo(_gp_disp)
4434; MIPS32R6-NEXT:    addu $1, $2, $25
4435; MIPS32R6-NEXT:    lw $1, %got(y)($1)
4436; MIPS32R6-NEXT:    addiu $2, $zero, -4
4437; MIPS32R6-NEXT:    and $3, $1, $2
4438; MIPS32R6-NEXT:    andi $1, $1, 3
4439; MIPS32R6-NEXT:    sll $1, $1, 3
4440; MIPS32R6-NEXT:    ori $2, $zero, 255
4441; MIPS32R6-NEXT:    sllv $6, $2, $1
4442; MIPS32R6-NEXT:    nor $7, $zero, $6
4443; MIPS32R6-NEXT:    andi $2, $4, 255
4444; MIPS32R6-NEXT:    sllv $4, $2, $1
4445; MIPS32R6-NEXT:    andi $2, $5, 255
4446; MIPS32R6-NEXT:    sllv $5, $2, $1
4447; MIPS32R6-NEXT:  $BB12_1: # %entry
4448; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
4449; MIPS32R6-NEXT:    ll $8, 0($3)
4450; MIPS32R6-NEXT:    and $9, $8, $6
4451; MIPS32R6-NEXT:    bnec $9, $4, $BB12_3
4452; MIPS32R6-NEXT:  # %bb.2: # %entry
4453; MIPS32R6-NEXT:    # in Loop: Header=BB12_1 Depth=1
4454; MIPS32R6-NEXT:    and $8, $8, $7
4455; MIPS32R6-NEXT:    or $8, $8, $5
4456; MIPS32R6-NEXT:    sc $8, 0($3)
4457; MIPS32R6-NEXT:    beqzc $8, $BB12_1
4458; MIPS32R6-NEXT:  $BB12_3: # %entry
4459; MIPS32R6-NEXT:    srlv $2, $9, $1
4460; MIPS32R6-NEXT:    seb $2, $2
4461; MIPS32R6-NEXT:  # %bb.4: # %entry
4462; MIPS32R6-NEXT:    jrc $ra
4463;
4464; MIPS32R6O0-LABEL: AtomicCmpSwap8:
4465; MIPS32R6O0:       # %bb.0: # %entry
4466; MIPS32R6O0-NEXT:    lui $2, %hi(_gp_disp)
4467; MIPS32R6O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
4468; MIPS32R6O0-NEXT:    addiu $sp, $sp, -8
4469; MIPS32R6O0-NEXT:    addu $3, $2, $25
4470; MIPS32R6O0-NEXT:    move $1, $5
4471; MIPS32R6O0-NEXT:    move $2, $4
4472; MIPS32R6O0-NEXT:    # kill: def $a1 killed $at
4473; MIPS32R6O0-NEXT:    # kill: def $a0 killed $v0
4474; MIPS32R6O0-NEXT:    lw $3, %got(y)($3)
4475; MIPS32R6O0-NEXT:    addiu $4, $zero, -4
4476; MIPS32R6O0-NEXT:    and $4, $3, $4
4477; MIPS32R6O0-NEXT:    andi $3, $3, 3
4478; MIPS32R6O0-NEXT:    sll $9, $3, 3
4479; MIPS32R6O0-NEXT:    ori $3, $zero, 255
4480; MIPS32R6O0-NEXT:    sllv $5, $3, $9
4481; MIPS32R6O0-NEXT:    nor $7, $zero, $5
4482; MIPS32R6O0-NEXT:    andi $2, $2, 255
4483; MIPS32R6O0-NEXT:    sllv $6, $2, $9
4484; MIPS32R6O0-NEXT:    andi $1, $1, 255
4485; MIPS32R6O0-NEXT:    sllv $8, $1, $9
4486; MIPS32R6O0-NEXT:  $BB12_1: # %entry
4487; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
4488; MIPS32R6O0-NEXT:    ll $2, 0($4)
4489; MIPS32R6O0-NEXT:    and $3, $2, $5
4490; MIPS32R6O0-NEXT:    bnec $3, $6, $BB12_3
4491; MIPS32R6O0-NEXT:  # %bb.2: # %entry
4492; MIPS32R6O0-NEXT:    # in Loop: Header=BB12_1 Depth=1
4493; MIPS32R6O0-NEXT:    and $2, $2, $7
4494; MIPS32R6O0-NEXT:    or $2, $2, $8
4495; MIPS32R6O0-NEXT:    sc $2, 0($4)
4496; MIPS32R6O0-NEXT:    beqzc $2, $BB12_1
4497; MIPS32R6O0-NEXT:  $BB12_3: # %entry
4498; MIPS32R6O0-NEXT:    srlv $1, $3, $9
4499; MIPS32R6O0-NEXT:    seb $1, $1
4500; MIPS32R6O0-NEXT:  # %bb.4: # %entry
4501; MIPS32R6O0-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
4502; MIPS32R6O0-NEXT:  # %bb.5: # %entry
4503; MIPS32R6O0-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
4504; MIPS32R6O0-NEXT:    addiu $sp, $sp, 8
4505; MIPS32R6O0-NEXT:    jrc $ra
4506;
4507; MIPS4-LABEL: AtomicCmpSwap8:
4508; MIPS4:       # %bb.0: # %entry
4509; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap8)))
4510; MIPS4-NEXT:    daddu $1, $1, $25
4511; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap8)))
4512; MIPS4-NEXT:    ld $1, %got_disp(y)($1)
4513; MIPS4-NEXT:    daddiu $2, $zero, -4
4514; MIPS4-NEXT:    and $2, $1, $2
4515; MIPS4-NEXT:    andi $1, $1, 3
4516; MIPS4-NEXT:    sll $3, $1, 3
4517; MIPS4-NEXT:    ori $1, $zero, 255
4518; MIPS4-NEXT:    sllv $6, $1, $3
4519; MIPS4-NEXT:    nor $7, $zero, $6
4520; MIPS4-NEXT:    andi $1, $4, 255
4521; MIPS4-NEXT:    sllv $4, $1, $3
4522; MIPS4-NEXT:    andi $1, $5, 255
4523; MIPS4-NEXT:    sllv $5, $1, $3
4524; MIPS4-NEXT:  .LBB12_1: # %entry
4525; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
4526; MIPS4-NEXT:    ll $8, 0($2)
4527; MIPS4-NEXT:    and $9, $8, $6
4528; MIPS4-NEXT:    bne $9, $4, .LBB12_3
4529; MIPS4-NEXT:    nop
4530; MIPS4-NEXT:  # %bb.2: # %entry
4531; MIPS4-NEXT:    # in Loop: Header=BB12_1 Depth=1
4532; MIPS4-NEXT:    and $8, $8, $7
4533; MIPS4-NEXT:    or $8, $8, $5
4534; MIPS4-NEXT:    sc $8, 0($2)
4535; MIPS4-NEXT:    beqz $8, .LBB12_1
4536; MIPS4-NEXT:    nop
4537; MIPS4-NEXT:  .LBB12_3: # %entry
4538; MIPS4-NEXT:    srlv $1, $9, $3
4539; MIPS4-NEXT:    sll $1, $1, 24
4540; MIPS4-NEXT:    sra $1, $1, 24
4541; MIPS4-NEXT:  # %bb.4: # %entry
4542; MIPS4-NEXT:    sll $1, $1, 24
4543; MIPS4-NEXT:    jr $ra
4544; MIPS4-NEXT:    sra $2, $1, 24
4545;
4546; MIPS64-LABEL: AtomicCmpSwap8:
4547; MIPS64:       # %bb.0: # %entry
4548; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap8)))
4549; MIPS64-NEXT:    daddu $1, $1, $25
4550; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap8)))
4551; MIPS64-NEXT:    ld $1, %got_disp(y)($1)
4552; MIPS64-NEXT:    daddiu $2, $zero, -4
4553; MIPS64-NEXT:    and $2, $1, $2
4554; MIPS64-NEXT:    andi $1, $1, 3
4555; MIPS64-NEXT:    sll $3, $1, 3
4556; MIPS64-NEXT:    ori $1, $zero, 255
4557; MIPS64-NEXT:    sllv $6, $1, $3
4558; MIPS64-NEXT:    nor $7, $zero, $6
4559; MIPS64-NEXT:    andi $1, $4, 255
4560; MIPS64-NEXT:    sllv $4, $1, $3
4561; MIPS64-NEXT:    andi $1, $5, 255
4562; MIPS64-NEXT:    sllv $5, $1, $3
4563; MIPS64-NEXT:  .LBB12_1: # %entry
4564; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
4565; MIPS64-NEXT:    ll $8, 0($2)
4566; MIPS64-NEXT:    and $9, $8, $6
4567; MIPS64-NEXT:    bne $9, $4, .LBB12_3
4568; MIPS64-NEXT:    nop
4569; MIPS64-NEXT:  # %bb.2: # %entry
4570; MIPS64-NEXT:    # in Loop: Header=BB12_1 Depth=1
4571; MIPS64-NEXT:    and $8, $8, $7
4572; MIPS64-NEXT:    or $8, $8, $5
4573; MIPS64-NEXT:    sc $8, 0($2)
4574; MIPS64-NEXT:    beqz $8, .LBB12_1
4575; MIPS64-NEXT:    nop
4576; MIPS64-NEXT:  .LBB12_3: # %entry
4577; MIPS64-NEXT:    srlv $1, $9, $3
4578; MIPS64-NEXT:    sll $1, $1, 24
4579; MIPS64-NEXT:    sra $1, $1, 24
4580; MIPS64-NEXT:  # %bb.4: # %entry
4581; MIPS64-NEXT:    sll $1, $1, 24
4582; MIPS64-NEXT:    jr $ra
4583; MIPS64-NEXT:    sra $2, $1, 24
4584;
4585; MIPS64R2-LABEL: AtomicCmpSwap8:
4586; MIPS64R2:       # %bb.0: # %entry
4587; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap8)))
4588; MIPS64R2-NEXT:    daddu $1, $1, $25
4589; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap8)))
4590; MIPS64R2-NEXT:    ld $1, %got_disp(y)($1)
4591; MIPS64R2-NEXT:    daddiu $2, $zero, -4
4592; MIPS64R2-NEXT:    and $3, $1, $2
4593; MIPS64R2-NEXT:    andi $1, $1, 3
4594; MIPS64R2-NEXT:    sll $1, $1, 3
4595; MIPS64R2-NEXT:    ori $2, $zero, 255
4596; MIPS64R2-NEXT:    sllv $6, $2, $1
4597; MIPS64R2-NEXT:    nor $7, $zero, $6
4598; MIPS64R2-NEXT:    andi $2, $4, 255
4599; MIPS64R2-NEXT:    sllv $4, $2, $1
4600; MIPS64R2-NEXT:    andi $2, $5, 255
4601; MIPS64R2-NEXT:    sllv $5, $2, $1
4602; MIPS64R2-NEXT:  .LBB12_1: # %entry
4603; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
4604; MIPS64R2-NEXT:    ll $8, 0($3)
4605; MIPS64R2-NEXT:    and $9, $8, $6
4606; MIPS64R2-NEXT:    bne $9, $4, .LBB12_3
4607; MIPS64R2-NEXT:    nop
4608; MIPS64R2-NEXT:  # %bb.2: # %entry
4609; MIPS64R2-NEXT:    # in Loop: Header=BB12_1 Depth=1
4610; MIPS64R2-NEXT:    and $8, $8, $7
4611; MIPS64R2-NEXT:    or $8, $8, $5
4612; MIPS64R2-NEXT:    sc $8, 0($3)
4613; MIPS64R2-NEXT:    beqz $8, .LBB12_1
4614; MIPS64R2-NEXT:    nop
4615; MIPS64R2-NEXT:  .LBB12_3: # %entry
4616; MIPS64R2-NEXT:    srlv $2, $9, $1
4617; MIPS64R2-NEXT:    seb $2, $2
4618; MIPS64R2-NEXT:  # %bb.4: # %entry
4619; MIPS64R2-NEXT:    jr $ra
4620; MIPS64R2-NEXT:    nop
4621;
4622; MIPS64R6-LABEL: AtomicCmpSwap8:
4623; MIPS64R6:       # %bb.0: # %entry
4624; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap8)))
4625; MIPS64R6-NEXT:    daddu $1, $1, $25
4626; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicCmpSwap8)))
4627; MIPS64R6-NEXT:    ld $1, %got_disp(y)($1)
4628; MIPS64R6-NEXT:    daddiu $2, $zero, -4
4629; MIPS64R6-NEXT:    and $3, $1, $2
4630; MIPS64R6-NEXT:    andi $1, $1, 3
4631; MIPS64R6-NEXT:    sll $1, $1, 3
4632; MIPS64R6-NEXT:    ori $2, $zero, 255
4633; MIPS64R6-NEXT:    sllv $6, $2, $1
4634; MIPS64R6-NEXT:    nor $7, $zero, $6
4635; MIPS64R6-NEXT:    andi $2, $4, 255
4636; MIPS64R6-NEXT:    sllv $4, $2, $1
4637; MIPS64R6-NEXT:    andi $2, $5, 255
4638; MIPS64R6-NEXT:    sllv $5, $2, $1
4639; MIPS64R6-NEXT:  .LBB12_1: # %entry
4640; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
4641; MIPS64R6-NEXT:    ll $8, 0($3)
4642; MIPS64R6-NEXT:    and $9, $8, $6
4643; MIPS64R6-NEXT:    bnec $9, $4, .LBB12_3
4644; MIPS64R6-NEXT:  # %bb.2: # %entry
4645; MIPS64R6-NEXT:    # in Loop: Header=BB12_1 Depth=1
4646; MIPS64R6-NEXT:    and $8, $8, $7
4647; MIPS64R6-NEXT:    or $8, $8, $5
4648; MIPS64R6-NEXT:    sc $8, 0($3)
4649; MIPS64R6-NEXT:    beqzc $8, .LBB12_1
4650; MIPS64R6-NEXT:  .LBB12_3: # %entry
4651; MIPS64R6-NEXT:    srlv $2, $9, $1
4652; MIPS64R6-NEXT:    seb $2, $2
4653; MIPS64R6-NEXT:  # %bb.4: # %entry
4654; MIPS64R6-NEXT:    jrc $ra
4655;
4656; MIPS64R6O0-LABEL: AtomicCmpSwap8:
4657; MIPS64R6O0:       # %bb.0: # %entry
4658; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -16
4659; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicCmpSwap8)))
4660; MIPS64R6O0-NEXT:    daddu $1, $1, $25
4661; MIPS64R6O0-NEXT:    daddiu $3, $1, %lo(%neg(%gp_rel(AtomicCmpSwap8)))
4662; MIPS64R6O0-NEXT:    move $1, $5
4663; MIPS64R6O0-NEXT:    move $2, $4
4664; MIPS64R6O0-NEXT:    ld $3, %got_disp(y)($3)
4665; MIPS64R6O0-NEXT:    daddiu $4, $zero, -4
4666; MIPS64R6O0-NEXT:    and $4, $3, $4
4667; MIPS64R6O0-NEXT:    andi $3, $3, 3
4668; MIPS64R6O0-NEXT:    xori $3, $3, 3
4669; MIPS64R6O0-NEXT:    sll $9, $3, 3
4670; MIPS64R6O0-NEXT:    ori $3, $zero, 255
4671; MIPS64R6O0-NEXT:    sllv $5, $3, $9
4672; MIPS64R6O0-NEXT:    nor $7, $zero, $5
4673; MIPS64R6O0-NEXT:    andi $2, $2, 255
4674; MIPS64R6O0-NEXT:    sllv $6, $2, $9
4675; MIPS64R6O0-NEXT:    andi $1, $1, 255
4676; MIPS64R6O0-NEXT:    sllv $8, $1, $9
4677; MIPS64R6O0-NEXT:  .LBB12_1: # %entry
4678; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
4679; MIPS64R6O0-NEXT:    ll $2, 0($4)
4680; MIPS64R6O0-NEXT:    and $3, $2, $5
4681; MIPS64R6O0-NEXT:    bnec $3, $6, .LBB12_3
4682; MIPS64R6O0-NEXT:  # %bb.2: # %entry
4683; MIPS64R6O0-NEXT:    # in Loop: Header=BB12_1 Depth=1
4684; MIPS64R6O0-NEXT:    and $2, $2, $7
4685; MIPS64R6O0-NEXT:    or $2, $2, $8
4686; MIPS64R6O0-NEXT:    sc $2, 0($4)
4687; MIPS64R6O0-NEXT:    beqzc $2, .LBB12_1
4688; MIPS64R6O0-NEXT:  .LBB12_3: # %entry
4689; MIPS64R6O0-NEXT:    srlv $1, $3, $9
4690; MIPS64R6O0-NEXT:    seb $1, $1
4691; MIPS64R6O0-NEXT:  # %bb.4: # %entry
4692; MIPS64R6O0-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
4693; MIPS64R6O0-NEXT:  # %bb.5: # %entry
4694; MIPS64R6O0-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
4695; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 16
4696; MIPS64R6O0-NEXT:    jrc $ra
4697;
4698; MM32-LABEL: AtomicCmpSwap8:
4699; MM32:       # %bb.0: # %entry
4700; MM32-NEXT:    lui $2, %hi(_gp_disp)
4701; MM32-NEXT:    addiu $2, $2, %lo(_gp_disp)
4702; MM32-NEXT:    addu $2, $2, $25
4703; MM32-NEXT:    lw $1, %got(y)($2)
4704; MM32-NEXT:    addiu $2, $zero, -4
4705; MM32-NEXT:    and $3, $1, $2
4706; MM32-NEXT:    andi $1, $1, 3
4707; MM32-NEXT:    sll $1, $1, 3
4708; MM32-NEXT:    ori $2, $zero, 255
4709; MM32-NEXT:    sllv $6, $2, $1
4710; MM32-NEXT:    nor $7, $zero, $6
4711; MM32-NEXT:    andi $2, $4, 255
4712; MM32-NEXT:    sllv $4, $2, $1
4713; MM32-NEXT:    andi $2, $5, 255
4714; MM32-NEXT:    sllv $5, $2, $1
4715; MM32-NEXT:  $BB12_1: # %entry
4716; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
4717; MM32-NEXT:    ll $8, 0($3)
4718; MM32-NEXT:    and $9, $8, $6
4719; MM32-NEXT:    bne $9, $4, $BB12_3
4720; MM32-NEXT:    nop
4721; MM32-NEXT:  # %bb.2: # %entry
4722; MM32-NEXT:    # in Loop: Header=BB12_1 Depth=1
4723; MM32-NEXT:    and $8, $8, $7
4724; MM32-NEXT:    or $8, $8, $5
4725; MM32-NEXT:    sc $8, 0($3)
4726; MM32-NEXT:    beqzc $8, $BB12_1
4727; MM32-NEXT:  $BB12_3: # %entry
4728; MM32-NEXT:    srlv $2, $9, $1
4729; MM32-NEXT:    seb $2, $2
4730; MM32-NEXT:  # %bb.4: # %entry
4731; MM32-NEXT:    jrc $ra
4732;
4733; O1-LABEL: AtomicCmpSwap8:
4734; O1:       # %bb.0: # %entry
4735; O1-NEXT:    lui $2, %hi(_gp_disp)
4736; O1-NEXT:    addiu $2, $2, %lo(_gp_disp)
4737; O1-NEXT:    addu $1, $2, $25
4738; O1-NEXT:    lw $1, %got(y)($1)
4739; O1-NEXT:    addiu $2, $zero, -4
4740; O1-NEXT:    and $2, $1, $2
4741; O1-NEXT:    andi $1, $1, 3
4742; O1-NEXT:    sll $3, $1, 3
4743; O1-NEXT:    ori $1, $zero, 255
4744; O1-NEXT:    sllv $6, $1, $3
4745; O1-NEXT:    nor $7, $zero, $6
4746; O1-NEXT:    andi $1, $4, 255
4747; O1-NEXT:    sllv $4, $1, $3
4748; O1-NEXT:    andi $1, $5, 255
4749; O1-NEXT:    sllv $5, $1, $3
4750; O1-NEXT:  $BB12_1: # %entry
4751; O1-NEXT:    # =>This Inner Loop Header: Depth=1
4752; O1-NEXT:    ll $8, 0($2)
4753; O1-NEXT:    and $9, $8, $6
4754; O1-NEXT:    bne $9, $4, $BB12_3
4755; O1-NEXT:    nop
4756; O1-NEXT:  # %bb.2: # %entry
4757; O1-NEXT:    # in Loop: Header=BB12_1 Depth=1
4758; O1-NEXT:    and $8, $8, $7
4759; O1-NEXT:    or $8, $8, $5
4760; O1-NEXT:    sc $8, 0($2)
4761; O1-NEXT:    beqz $8, $BB12_1
4762; O1-NEXT:    nop
4763; O1-NEXT:  $BB12_3: # %entry
4764; O1-NEXT:    srlv $1, $9, $3
4765; O1-NEXT:    sll $1, $1, 24
4766; O1-NEXT:    sra $1, $1, 24
4767; O1-NEXT:  # %bb.4: # %entry
4768; O1-NEXT:    sll $1, $1, 24
4769; O1-NEXT:    jr $ra
4770; O1-NEXT:    sra $2, $1, 24
4771;
4772; O2-LABEL: AtomicCmpSwap8:
4773; O2:       # %bb.0: # %entry
4774; O2-NEXT:    lui $2, %hi(_gp_disp)
4775; O2-NEXT:    addiu $2, $2, %lo(_gp_disp)
4776; O2-NEXT:    addu $1, $2, $25
4777; O2-NEXT:    lw $1, %got(y)($1)
4778; O2-NEXT:    addiu $2, $zero, -4
4779; O2-NEXT:    and $2, $1, $2
4780; O2-NEXT:    andi $1, $1, 3
4781; O2-NEXT:    sll $3, $1, 3
4782; O2-NEXT:    ori $1, $zero, 255
4783; O2-NEXT:    sllv $6, $1, $3
4784; O2-NEXT:    nor $7, $zero, $6
4785; O2-NEXT:    andi $1, $4, 255
4786; O2-NEXT:    sllv $4, $1, $3
4787; O2-NEXT:    andi $1, $5, 255
4788; O2-NEXT:    sllv $5, $1, $3
4789; O2-NEXT:  $BB12_1: # %entry
4790; O2-NEXT:    # =>This Inner Loop Header: Depth=1
4791; O2-NEXT:    ll $8, 0($2)
4792; O2-NEXT:    and $9, $8, $6
4793; O2-NEXT:    bne $9, $4, $BB12_3
4794; O2-NEXT:    nop
4795; O2-NEXT:  # %bb.2: # %entry
4796; O2-NEXT:    # in Loop: Header=BB12_1 Depth=1
4797; O2-NEXT:    and $8, $8, $7
4798; O2-NEXT:    or $8, $8, $5
4799; O2-NEXT:    sc $8, 0($2)
4800; O2-NEXT:    beqz $8, $BB12_1
4801; O2-NEXT:    nop
4802; O2-NEXT:  $BB12_3: # %entry
4803; O2-NEXT:    srlv $1, $9, $3
4804; O2-NEXT:    sll $1, $1, 24
4805; O2-NEXT:    sra $1, $1, 24
4806; O2-NEXT:  # %bb.4: # %entry
4807; O2-NEXT:    sll $1, $1, 24
4808; O2-NEXT:    jr $ra
4809; O2-NEXT:    sra $2, $1, 24
4810;
4811; O3-LABEL: AtomicCmpSwap8:
4812; O3:       # %bb.0: # %entry
4813; O3-NEXT:    lui $2, %hi(_gp_disp)
4814; O3-NEXT:    addiu $2, $2, %lo(_gp_disp)
4815; O3-NEXT:    addu $1, $2, $25
4816; O3-NEXT:    addiu $2, $zero, -4
4817; O3-NEXT:    lw $1, %got(y)($1)
4818; O3-NEXT:    and $2, $1, $2
4819; O3-NEXT:    andi $1, $1, 3
4820; O3-NEXT:    sll $3, $1, 3
4821; O3-NEXT:    ori $1, $zero, 255
4822; O3-NEXT:    sllv $6, $1, $3
4823; O3-NEXT:    andi $1, $4, 255
4824; O3-NEXT:    sllv $4, $1, $3
4825; O3-NEXT:    andi $1, $5, 255
4826; O3-NEXT:    nor $7, $zero, $6
4827; O3-NEXT:    sllv $5, $1, $3
4828; O3-NEXT:  $BB12_1: # %entry
4829; O3-NEXT:    # =>This Inner Loop Header: Depth=1
4830; O3-NEXT:    ll $8, 0($2)
4831; O3-NEXT:    and $9, $8, $6
4832; O3-NEXT:    bne $9, $4, $BB12_3
4833; O3-NEXT:    nop
4834; O3-NEXT:  # %bb.2: # %entry
4835; O3-NEXT:    # in Loop: Header=BB12_1 Depth=1
4836; O3-NEXT:    and $8, $8, $7
4837; O3-NEXT:    or $8, $8, $5
4838; O3-NEXT:    sc $8, 0($2)
4839; O3-NEXT:    beqz $8, $BB12_1
4840; O3-NEXT:    nop
4841; O3-NEXT:  $BB12_3: # %entry
4842; O3-NEXT:    srlv $1, $9, $3
4843; O3-NEXT:    sll $1, $1, 24
4844; O3-NEXT:    sra $1, $1, 24
4845; O3-NEXT:  # %bb.4: # %entry
4846; O3-NEXT:    sll $1, $1, 24
4847; O3-NEXT:    jr $ra
4848; O3-NEXT:    sra $2, $1, 24
4849;
4850; MIPS32EB-LABEL: AtomicCmpSwap8:
4851; MIPS32EB:       # %bb.0: # %entry
4852; MIPS32EB-NEXT:    lui $2, %hi(_gp_disp)
4853; MIPS32EB-NEXT:    addiu $2, $2, %lo(_gp_disp)
4854; MIPS32EB-NEXT:    addu $1, $2, $25
4855; MIPS32EB-NEXT:    lw $1, %got(y)($1)
4856; MIPS32EB-NEXT:    addiu $2, $zero, -4
4857; MIPS32EB-NEXT:    and $2, $1, $2
4858; MIPS32EB-NEXT:    andi $1, $1, 3
4859; MIPS32EB-NEXT:    xori $1, $1, 3
4860; MIPS32EB-NEXT:    sll $3, $1, 3
4861; MIPS32EB-NEXT:    ori $1, $zero, 255
4862; MIPS32EB-NEXT:    sllv $6, $1, $3
4863; MIPS32EB-NEXT:    nor $7, $zero, $6
4864; MIPS32EB-NEXT:    andi $1, $4, 255
4865; MIPS32EB-NEXT:    sllv $4, $1, $3
4866; MIPS32EB-NEXT:    andi $1, $5, 255
4867; MIPS32EB-NEXT:    sllv $5, $1, $3
4868; MIPS32EB-NEXT:  $BB12_1: # %entry
4869; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
4870; MIPS32EB-NEXT:    ll $8, 0($2)
4871; MIPS32EB-NEXT:    and $9, $8, $6
4872; MIPS32EB-NEXT:    bne $9, $4, $BB12_3
4873; MIPS32EB-NEXT:    nop
4874; MIPS32EB-NEXT:  # %bb.2: # %entry
4875; MIPS32EB-NEXT:    # in Loop: Header=BB12_1 Depth=1
4876; MIPS32EB-NEXT:    and $8, $8, $7
4877; MIPS32EB-NEXT:    or $8, $8, $5
4878; MIPS32EB-NEXT:    sc $8, 0($2)
4879; MIPS32EB-NEXT:    beqz $8, $BB12_1
4880; MIPS32EB-NEXT:    nop
4881; MIPS32EB-NEXT:  $BB12_3: # %entry
4882; MIPS32EB-NEXT:    srlv $1, $9, $3
4883; MIPS32EB-NEXT:    sll $1, $1, 24
4884; MIPS32EB-NEXT:    sra $1, $1, 24
4885; MIPS32EB-NEXT:  # %bb.4: # %entry
4886; MIPS32EB-NEXT:    sll $1, $1, 24
4887; MIPS32EB-NEXT:    jr $ra
4888; MIPS32EB-NEXT:    sra $2, $1, 24
4889entry:
4890  %pair0 = cmpxchg i8* @y, i8 %oldval, i8 %newval monotonic monotonic
4891  %0 = extractvalue { i8, i1 } %pair0, 0
4892  ret i8 %0
4893}
4894
4895define i1 @AtomicCmpSwapRes8(i8* %ptr, i8 signext %oldval, i8 signext %newval) nounwind {
4896; MIPS32-LABEL: AtomicCmpSwapRes8:
4897; MIPS32:       # %bb.0: # %entry
4898; MIPS32-NEXT:    addiu $1, $zero, -4
4899; MIPS32-NEXT:    and $2, $4, $1
4900; MIPS32-NEXT:    andi $1, $4, 3
4901; MIPS32-NEXT:    sll $3, $1, 3
4902; MIPS32-NEXT:    ori $1, $zero, 255
4903; MIPS32-NEXT:    sllv $4, $1, $3
4904; MIPS32-NEXT:    nor $7, $zero, $4
4905; MIPS32-NEXT:    andi $1, $5, 255
4906; MIPS32-NEXT:    sllv $8, $1, $3
4907; MIPS32-NEXT:    andi $1, $6, 255
4908; MIPS32-NEXT:    sllv $6, $1, $3
4909; MIPS32-NEXT:  $BB13_1: # %entry
4910; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
4911; MIPS32-NEXT:    ll $9, 0($2)
4912; MIPS32-NEXT:    and $10, $9, $4
4913; MIPS32-NEXT:    bne $10, $8, $BB13_3
4914; MIPS32-NEXT:    nop
4915; MIPS32-NEXT:  # %bb.2: # %entry
4916; MIPS32-NEXT:    # in Loop: Header=BB13_1 Depth=1
4917; MIPS32-NEXT:    and $9, $9, $7
4918; MIPS32-NEXT:    or $9, $9, $6
4919; MIPS32-NEXT:    sc $9, 0($2)
4920; MIPS32-NEXT:    beqz $9, $BB13_1
4921; MIPS32-NEXT:    nop
4922; MIPS32-NEXT:  $BB13_3: # %entry
4923; MIPS32-NEXT:    srlv $1, $10, $3
4924; MIPS32-NEXT:    sll $1, $1, 24
4925; MIPS32-NEXT:    sra $1, $1, 24
4926; MIPS32-NEXT:  # %bb.4: # %entry
4927; MIPS32-NEXT:    sll $2, $5, 24
4928; MIPS32-NEXT:    sra $2, $2, 24
4929; MIPS32-NEXT:    xor $1, $1, $2
4930; MIPS32-NEXT:    jr $ra
4931; MIPS32-NEXT:    sltiu $2, $1, 1
4932;
4933; MIPS32O0-LABEL: AtomicCmpSwapRes8:
4934; MIPS32O0:       # %bb.0: # %entry
4935; MIPS32O0-NEXT:    addiu $sp, $sp, -8
4936; MIPS32O0-NEXT:    move $1, $6
4937; MIPS32O0-NEXT:    move $2, $5
4938; MIPS32O0-NEXT:    move $3, $4
4939; MIPS32O0-NEXT:    sw $2, 0($sp) # 4-byte Folded Spill
4940; MIPS32O0-NEXT:    addiu $4, $zero, -4
4941; MIPS32O0-NEXT:    and $4, $3, $4
4942; MIPS32O0-NEXT:    andi $3, $3, 3
4943; MIPS32O0-NEXT:    sll $9, $3, 3
4944; MIPS32O0-NEXT:    ori $3, $zero, 255
4945; MIPS32O0-NEXT:    sllv $5, $3, $9
4946; MIPS32O0-NEXT:    nor $7, $zero, $5
4947; MIPS32O0-NEXT:    andi $2, $2, 255
4948; MIPS32O0-NEXT:    sllv $6, $2, $9
4949; MIPS32O0-NEXT:    andi $1, $1, 255
4950; MIPS32O0-NEXT:    sllv $8, $1, $9
4951; MIPS32O0-NEXT:  $BB13_1: # %entry
4952; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
4953; MIPS32O0-NEXT:    ll $2, 0($4)
4954; MIPS32O0-NEXT:    and $3, $2, $5
4955; MIPS32O0-NEXT:    bne $3, $6, $BB13_3
4956; MIPS32O0-NEXT:    nop
4957; MIPS32O0-NEXT:  # %bb.2: # %entry
4958; MIPS32O0-NEXT:    # in Loop: Header=BB13_1 Depth=1
4959; MIPS32O0-NEXT:    and $2, $2, $7
4960; MIPS32O0-NEXT:    or $2, $2, $8
4961; MIPS32O0-NEXT:    sc $2, 0($4)
4962; MIPS32O0-NEXT:    beqz $2, $BB13_1
4963; MIPS32O0-NEXT:    nop
4964; MIPS32O0-NEXT:  $BB13_3: # %entry
4965; MIPS32O0-NEXT:    srlv $1, $3, $9
4966; MIPS32O0-NEXT:    sll $1, $1, 24
4967; MIPS32O0-NEXT:    sra $1, $1, 24
4968; MIPS32O0-NEXT:  # %bb.4: # %entry
4969; MIPS32O0-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
4970; MIPS32O0-NEXT:  # %bb.5: # %entry
4971; MIPS32O0-NEXT:    lw $1, 4($sp) # 4-byte Folded Reload
4972; MIPS32O0-NEXT:    lw $2, 0($sp) # 4-byte Folded Reload
4973; MIPS32O0-NEXT:    sll $2, $2, 24
4974; MIPS32O0-NEXT:    sra $2, $2, 24
4975; MIPS32O0-NEXT:    xor $1, $1, $2
4976; MIPS32O0-NEXT:    sltiu $2, $1, 1
4977; MIPS32O0-NEXT:    addiu $sp, $sp, 8
4978; MIPS32O0-NEXT:    jr $ra
4979; MIPS32O0-NEXT:    nop
4980;
4981; MIPS32R2-LABEL: AtomicCmpSwapRes8:
4982; MIPS32R2:       # %bb.0: # %entry
4983; MIPS32R2-NEXT:    addiu $1, $zero, -4
4984; MIPS32R2-NEXT:    and $2, $4, $1
4985; MIPS32R2-NEXT:    andi $1, $4, 3
4986; MIPS32R2-NEXT:    sll $3, $1, 3
4987; MIPS32R2-NEXT:    ori $1, $zero, 255
4988; MIPS32R2-NEXT:    sllv $4, $1, $3
4989; MIPS32R2-NEXT:    nor $7, $zero, $4
4990; MIPS32R2-NEXT:    andi $1, $5, 255
4991; MIPS32R2-NEXT:    sllv $8, $1, $3
4992; MIPS32R2-NEXT:    andi $1, $6, 255
4993; MIPS32R2-NEXT:    sllv $6, $1, $3
4994; MIPS32R2-NEXT:  $BB13_1: # %entry
4995; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
4996; MIPS32R2-NEXT:    ll $9, 0($2)
4997; MIPS32R2-NEXT:    and $10, $9, $4
4998; MIPS32R2-NEXT:    bne $10, $8, $BB13_3
4999; MIPS32R2-NEXT:    nop
5000; MIPS32R2-NEXT:  # %bb.2: # %entry
5001; MIPS32R2-NEXT:    # in Loop: Header=BB13_1 Depth=1
5002; MIPS32R2-NEXT:    and $9, $9, $7
5003; MIPS32R2-NEXT:    or $9, $9, $6
5004; MIPS32R2-NEXT:    sc $9, 0($2)
5005; MIPS32R2-NEXT:    beqz $9, $BB13_1
5006; MIPS32R2-NEXT:    nop
5007; MIPS32R2-NEXT:  $BB13_3: # %entry
5008; MIPS32R2-NEXT:    srlv $1, $10, $3
5009; MIPS32R2-NEXT:    seb $1, $1
5010; MIPS32R2-NEXT:  # %bb.4: # %entry
5011; MIPS32R2-NEXT:    xor $1, $1, $5
5012; MIPS32R2-NEXT:    jr $ra
5013; MIPS32R2-NEXT:    sltiu $2, $1, 1
5014;
5015; MIPS32R6-LABEL: AtomicCmpSwapRes8:
5016; MIPS32R6:       # %bb.0: # %entry
5017; MIPS32R6-NEXT:    addiu $1, $zero, -4
5018; MIPS32R6-NEXT:    and $2, $4, $1
5019; MIPS32R6-NEXT:    andi $1, $4, 3
5020; MIPS32R6-NEXT:    sll $3, $1, 3
5021; MIPS32R6-NEXT:    ori $1, $zero, 255
5022; MIPS32R6-NEXT:    sllv $4, $1, $3
5023; MIPS32R6-NEXT:    nor $7, $zero, $4
5024; MIPS32R6-NEXT:    andi $1, $5, 255
5025; MIPS32R6-NEXT:    sllv $8, $1, $3
5026; MIPS32R6-NEXT:    andi $1, $6, 255
5027; MIPS32R6-NEXT:    sllv $6, $1, $3
5028; MIPS32R6-NEXT:  $BB13_1: # %entry
5029; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
5030; MIPS32R6-NEXT:    ll $9, 0($2)
5031; MIPS32R6-NEXT:    and $10, $9, $4
5032; MIPS32R6-NEXT:    bnec $10, $8, $BB13_3
5033; MIPS32R6-NEXT:  # %bb.2: # %entry
5034; MIPS32R6-NEXT:    # in Loop: Header=BB13_1 Depth=1
5035; MIPS32R6-NEXT:    and $9, $9, $7
5036; MIPS32R6-NEXT:    or $9, $9, $6
5037; MIPS32R6-NEXT:    sc $9, 0($2)
5038; MIPS32R6-NEXT:    beqzc $9, $BB13_1
5039; MIPS32R6-NEXT:  $BB13_3: # %entry
5040; MIPS32R6-NEXT:    srlv $1, $10, $3
5041; MIPS32R6-NEXT:    seb $1, $1
5042; MIPS32R6-NEXT:  # %bb.4: # %entry
5043; MIPS32R6-NEXT:    xor $1, $1, $5
5044; MIPS32R6-NEXT:    jr $ra
5045; MIPS32R6-NEXT:    sltiu $2, $1, 1
5046;
5047; MIPS32R6O0-LABEL: AtomicCmpSwapRes8:
5048; MIPS32R6O0:       # %bb.0: # %entry
5049; MIPS32R6O0-NEXT:    addiu $sp, $sp, -8
5050; MIPS32R6O0-NEXT:    move $1, $6
5051; MIPS32R6O0-NEXT:    move $2, $5
5052; MIPS32R6O0-NEXT:    sw $2, 0($sp) # 4-byte Folded Spill
5053; MIPS32R6O0-NEXT:    move $3, $4
5054; MIPS32R6O0-NEXT:    # kill: def $a2 killed $at
5055; MIPS32R6O0-NEXT:    # kill: def $a1 killed $v0
5056; MIPS32R6O0-NEXT:    addiu $4, $zero, -4
5057; MIPS32R6O0-NEXT:    and $4, $3, $4
5058; MIPS32R6O0-NEXT:    andi $3, $3, 3
5059; MIPS32R6O0-NEXT:    sll $9, $3, 3
5060; MIPS32R6O0-NEXT:    ori $3, $zero, 255
5061; MIPS32R6O0-NEXT:    sllv $5, $3, $9
5062; MIPS32R6O0-NEXT:    nor $7, $zero, $5
5063; MIPS32R6O0-NEXT:    andi $2, $2, 255
5064; MIPS32R6O0-NEXT:    sllv $6, $2, $9
5065; MIPS32R6O0-NEXT:    andi $1, $1, 255
5066; MIPS32R6O0-NEXT:    sllv $8, $1, $9
5067; MIPS32R6O0-NEXT:  $BB13_1: # %entry
5068; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
5069; MIPS32R6O0-NEXT:    ll $2, 0($4)
5070; MIPS32R6O0-NEXT:    and $3, $2, $5
5071; MIPS32R6O0-NEXT:    bnec $3, $6, $BB13_3
5072; MIPS32R6O0-NEXT:  # %bb.2: # %entry
5073; MIPS32R6O0-NEXT:    # in Loop: Header=BB13_1 Depth=1
5074; MIPS32R6O0-NEXT:    and $2, $2, $7
5075; MIPS32R6O0-NEXT:    or $2, $2, $8
5076; MIPS32R6O0-NEXT:    sc $2, 0($4)
5077; MIPS32R6O0-NEXT:    beqzc $2, $BB13_1
5078; MIPS32R6O0-NEXT:  $BB13_3: # %entry
5079; MIPS32R6O0-NEXT:    srlv $1, $3, $9
5080; MIPS32R6O0-NEXT:    seb $1, $1
5081; MIPS32R6O0-NEXT:  # %bb.4: # %entry
5082; MIPS32R6O0-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
5083; MIPS32R6O0-NEXT:  # %bb.5: # %entry
5084; MIPS32R6O0-NEXT:    lw $1, 4($sp) # 4-byte Folded Reload
5085; MIPS32R6O0-NEXT:    lw $2, 0($sp) # 4-byte Folded Reload
5086; MIPS32R6O0-NEXT:    xor $1, $1, $2
5087; MIPS32R6O0-NEXT:    sltiu $2, $1, 1
5088; MIPS32R6O0-NEXT:    addiu $sp, $sp, 8
5089; MIPS32R6O0-NEXT:    jrc $ra
5090;
5091; MIPS4-LABEL: AtomicCmpSwapRes8:
5092; MIPS4:       # %bb.0: # %entry
5093; MIPS4-NEXT:    daddiu $1, $zero, -4
5094; MIPS4-NEXT:    and $2, $4, $1
5095; MIPS4-NEXT:    andi $1, $4, 3
5096; MIPS4-NEXT:    sll $3, $1, 3
5097; MIPS4-NEXT:    ori $1, $zero, 255
5098; MIPS4-NEXT:    sllv $4, $1, $3
5099; MIPS4-NEXT:    nor $7, $zero, $4
5100; MIPS4-NEXT:    andi $1, $5, 255
5101; MIPS4-NEXT:    sllv $8, $1, $3
5102; MIPS4-NEXT:    andi $1, $6, 255
5103; MIPS4-NEXT:    sllv $6, $1, $3
5104; MIPS4-NEXT:  .LBB13_1: # %entry
5105; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
5106; MIPS4-NEXT:    ll $9, 0($2)
5107; MIPS4-NEXT:    and $10, $9, $4
5108; MIPS4-NEXT:    bne $10, $8, .LBB13_3
5109; MIPS4-NEXT:    nop
5110; MIPS4-NEXT:  # %bb.2: # %entry
5111; MIPS4-NEXT:    # in Loop: Header=BB13_1 Depth=1
5112; MIPS4-NEXT:    and $9, $9, $7
5113; MIPS4-NEXT:    or $9, $9, $6
5114; MIPS4-NEXT:    sc $9, 0($2)
5115; MIPS4-NEXT:    beqz $9, .LBB13_1
5116; MIPS4-NEXT:    nop
5117; MIPS4-NEXT:  .LBB13_3: # %entry
5118; MIPS4-NEXT:    srlv $1, $10, $3
5119; MIPS4-NEXT:    sll $1, $1, 24
5120; MIPS4-NEXT:    sra $1, $1, 24
5121; MIPS4-NEXT:  # %bb.4: # %entry
5122; MIPS4-NEXT:    sll $2, $5, 24
5123; MIPS4-NEXT:    sra $2, $2, 24
5124; MIPS4-NEXT:    xor $1, $1, $2
5125; MIPS4-NEXT:    jr $ra
5126; MIPS4-NEXT:    sltiu $2, $1, 1
5127;
5128; MIPS64-LABEL: AtomicCmpSwapRes8:
5129; MIPS64:       # %bb.0: # %entry
5130; MIPS64-NEXT:    daddiu $1, $zero, -4
5131; MIPS64-NEXT:    and $2, $4, $1
5132; MIPS64-NEXT:    andi $1, $4, 3
5133; MIPS64-NEXT:    sll $3, $1, 3
5134; MIPS64-NEXT:    ori $1, $zero, 255
5135; MIPS64-NEXT:    sllv $4, $1, $3
5136; MIPS64-NEXT:    nor $7, $zero, $4
5137; MIPS64-NEXT:    andi $1, $5, 255
5138; MIPS64-NEXT:    sllv $8, $1, $3
5139; MIPS64-NEXT:    andi $1, $6, 255
5140; MIPS64-NEXT:    sllv $6, $1, $3
5141; MIPS64-NEXT:  .LBB13_1: # %entry
5142; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
5143; MIPS64-NEXT:    ll $9, 0($2)
5144; MIPS64-NEXT:    and $10, $9, $4
5145; MIPS64-NEXT:    bne $10, $8, .LBB13_3
5146; MIPS64-NEXT:    nop
5147; MIPS64-NEXT:  # %bb.2: # %entry
5148; MIPS64-NEXT:    # in Loop: Header=BB13_1 Depth=1
5149; MIPS64-NEXT:    and $9, $9, $7
5150; MIPS64-NEXT:    or $9, $9, $6
5151; MIPS64-NEXT:    sc $9, 0($2)
5152; MIPS64-NEXT:    beqz $9, .LBB13_1
5153; MIPS64-NEXT:    nop
5154; MIPS64-NEXT:  .LBB13_3: # %entry
5155; MIPS64-NEXT:    srlv $1, $10, $3
5156; MIPS64-NEXT:    sll $1, $1, 24
5157; MIPS64-NEXT:    sra $1, $1, 24
5158; MIPS64-NEXT:  # %bb.4: # %entry
5159; MIPS64-NEXT:    sll $2, $5, 24
5160; MIPS64-NEXT:    sra $2, $2, 24
5161; MIPS64-NEXT:    xor $1, $1, $2
5162; MIPS64-NEXT:    jr $ra
5163; MIPS64-NEXT:    sltiu $2, $1, 1
5164;
5165; MIPS64R2-LABEL: AtomicCmpSwapRes8:
5166; MIPS64R2:       # %bb.0: # %entry
5167; MIPS64R2-NEXT:    daddiu $1, $zero, -4
5168; MIPS64R2-NEXT:    and $2, $4, $1
5169; MIPS64R2-NEXT:    andi $1, $4, 3
5170; MIPS64R2-NEXT:    sll $3, $1, 3
5171; MIPS64R2-NEXT:    ori $1, $zero, 255
5172; MIPS64R2-NEXT:    sllv $4, $1, $3
5173; MIPS64R2-NEXT:    nor $7, $zero, $4
5174; MIPS64R2-NEXT:    andi $1, $5, 255
5175; MIPS64R2-NEXT:    sllv $8, $1, $3
5176; MIPS64R2-NEXT:    andi $1, $6, 255
5177; MIPS64R2-NEXT:    sllv $6, $1, $3
5178; MIPS64R2-NEXT:  .LBB13_1: # %entry
5179; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
5180; MIPS64R2-NEXT:    ll $9, 0($2)
5181; MIPS64R2-NEXT:    and $10, $9, $4
5182; MIPS64R2-NEXT:    bne $10, $8, .LBB13_3
5183; MIPS64R2-NEXT:    nop
5184; MIPS64R2-NEXT:  # %bb.2: # %entry
5185; MIPS64R2-NEXT:    # in Loop: Header=BB13_1 Depth=1
5186; MIPS64R2-NEXT:    and $9, $9, $7
5187; MIPS64R2-NEXT:    or $9, $9, $6
5188; MIPS64R2-NEXT:    sc $9, 0($2)
5189; MIPS64R2-NEXT:    beqz $9, .LBB13_1
5190; MIPS64R2-NEXT:    nop
5191; MIPS64R2-NEXT:  .LBB13_3: # %entry
5192; MIPS64R2-NEXT:    srlv $1, $10, $3
5193; MIPS64R2-NEXT:    seb $1, $1
5194; MIPS64R2-NEXT:  # %bb.4: # %entry
5195; MIPS64R2-NEXT:    xor $1, $1, $5
5196; MIPS64R2-NEXT:    jr $ra
5197; MIPS64R2-NEXT:    sltiu $2, $1, 1
5198;
5199; MIPS64R6-LABEL: AtomicCmpSwapRes8:
5200; MIPS64R6:       # %bb.0: # %entry
5201; MIPS64R6-NEXT:    daddiu $1, $zero, -4
5202; MIPS64R6-NEXT:    and $2, $4, $1
5203; MIPS64R6-NEXT:    andi $1, $4, 3
5204; MIPS64R6-NEXT:    sll $3, $1, 3
5205; MIPS64R6-NEXT:    ori $1, $zero, 255
5206; MIPS64R6-NEXT:    sllv $4, $1, $3
5207; MIPS64R6-NEXT:    nor $7, $zero, $4
5208; MIPS64R6-NEXT:    andi $1, $5, 255
5209; MIPS64R6-NEXT:    sllv $8, $1, $3
5210; MIPS64R6-NEXT:    andi $1, $6, 255
5211; MIPS64R6-NEXT:    sllv $6, $1, $3
5212; MIPS64R6-NEXT:  .LBB13_1: # %entry
5213; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
5214; MIPS64R6-NEXT:    ll $9, 0($2)
5215; MIPS64R6-NEXT:    and $10, $9, $4
5216; MIPS64R6-NEXT:    bnec $10, $8, .LBB13_3
5217; MIPS64R6-NEXT:  # %bb.2: # %entry
5218; MIPS64R6-NEXT:    # in Loop: Header=BB13_1 Depth=1
5219; MIPS64R6-NEXT:    and $9, $9, $7
5220; MIPS64R6-NEXT:    or $9, $9, $6
5221; MIPS64R6-NEXT:    sc $9, 0($2)
5222; MIPS64R6-NEXT:    beqzc $9, .LBB13_1
5223; MIPS64R6-NEXT:  .LBB13_3: # %entry
5224; MIPS64R6-NEXT:    srlv $1, $10, $3
5225; MIPS64R6-NEXT:    seb $1, $1
5226; MIPS64R6-NEXT:  # %bb.4: # %entry
5227; MIPS64R6-NEXT:    xor $1, $1, $5
5228; MIPS64R6-NEXT:    jr $ra
5229; MIPS64R6-NEXT:    sltiu $2, $1, 1
5230;
5231; MIPS64R6O0-LABEL: AtomicCmpSwapRes8:
5232; MIPS64R6O0:       # %bb.0: # %entry
5233; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -16
5234; MIPS64R6O0-NEXT:    move $3, $4
5235; MIPS64R6O0-NEXT:    move $1, $6
5236; MIPS64R6O0-NEXT:    move $2, $5
5237; MIPS64R6O0-NEXT:    sw $2, 8($sp) # 4-byte Folded Spill
5238; MIPS64R6O0-NEXT:    daddiu $4, $zero, -4
5239; MIPS64R6O0-NEXT:    and $4, $3, $4
5240; MIPS64R6O0-NEXT:    andi $3, $3, 3
5241; MIPS64R6O0-NEXT:    xori $3, $3, 3
5242; MIPS64R6O0-NEXT:    sll $9, $3, 3
5243; MIPS64R6O0-NEXT:    ori $3, $zero, 255
5244; MIPS64R6O0-NEXT:    sllv $5, $3, $9
5245; MIPS64R6O0-NEXT:    nor $7, $zero, $5
5246; MIPS64R6O0-NEXT:    andi $2, $2, 255
5247; MIPS64R6O0-NEXT:    sllv $6, $2, $9
5248; MIPS64R6O0-NEXT:    andi $1, $1, 255
5249; MIPS64R6O0-NEXT:    sllv $8, $1, $9
5250; MIPS64R6O0-NEXT:  .LBB13_1: # %entry
5251; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
5252; MIPS64R6O0-NEXT:    ll $2, 0($4)
5253; MIPS64R6O0-NEXT:    and $3, $2, $5
5254; MIPS64R6O0-NEXT:    bnec $3, $6, .LBB13_3
5255; MIPS64R6O0-NEXT:  # %bb.2: # %entry
5256; MIPS64R6O0-NEXT:    # in Loop: Header=BB13_1 Depth=1
5257; MIPS64R6O0-NEXT:    and $2, $2, $7
5258; MIPS64R6O0-NEXT:    or $2, $2, $8
5259; MIPS64R6O0-NEXT:    sc $2, 0($4)
5260; MIPS64R6O0-NEXT:    beqzc $2, .LBB13_1
5261; MIPS64R6O0-NEXT:  .LBB13_3: # %entry
5262; MIPS64R6O0-NEXT:    srlv $1, $3, $9
5263; MIPS64R6O0-NEXT:    seb $1, $1
5264; MIPS64R6O0-NEXT:  # %bb.4: # %entry
5265; MIPS64R6O0-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
5266; MIPS64R6O0-NEXT:  # %bb.5: # %entry
5267; MIPS64R6O0-NEXT:    lw $1, 12($sp) # 4-byte Folded Reload
5268; MIPS64R6O0-NEXT:    lw $2, 8($sp) # 4-byte Folded Reload
5269; MIPS64R6O0-NEXT:    xor $1, $1, $2
5270; MIPS64R6O0-NEXT:    sltiu $2, $1, 1
5271; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 16
5272; MIPS64R6O0-NEXT:    jrc $ra
5273;
5274; MM32-LABEL: AtomicCmpSwapRes8:
5275; MM32:       # %bb.0: # %entry
5276; MM32-NEXT:    addiu $1, $zero, -4
5277; MM32-NEXT:    and $2, $4, $1
5278; MM32-NEXT:    andi $1, $4, 3
5279; MM32-NEXT:    sll $3, $1, 3
5280; MM32-NEXT:    ori $1, $zero, 255
5281; MM32-NEXT:    sllv $4, $1, $3
5282; MM32-NEXT:    nor $7, $zero, $4
5283; MM32-NEXT:    andi $1, $5, 255
5284; MM32-NEXT:    sllv $8, $1, $3
5285; MM32-NEXT:    andi $1, $6, 255
5286; MM32-NEXT:    sllv $6, $1, $3
5287; MM32-NEXT:  $BB13_1: # %entry
5288; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
5289; MM32-NEXT:    ll $9, 0($2)
5290; MM32-NEXT:    and $10, $9, $4
5291; MM32-NEXT:    bne $10, $8, $BB13_3
5292; MM32-NEXT:    nop
5293; MM32-NEXT:  # %bb.2: # %entry
5294; MM32-NEXT:    # in Loop: Header=BB13_1 Depth=1
5295; MM32-NEXT:    and $9, $9, $7
5296; MM32-NEXT:    or $9, $9, $6
5297; MM32-NEXT:    sc $9, 0($2)
5298; MM32-NEXT:    beqzc $9, $BB13_1
5299; MM32-NEXT:  $BB13_3: # %entry
5300; MM32-NEXT:    srlv $1, $10, $3
5301; MM32-NEXT:    seb $1, $1
5302; MM32-NEXT:  # %bb.4: # %entry
5303; MM32-NEXT:    xor $1, $1, $5
5304; MM32-NEXT:    jr $ra
5305; MM32-NEXT:    sltiu $2, $1, 1
5306;
5307; O1-LABEL: AtomicCmpSwapRes8:
5308; O1:       # %bb.0: # %entry
5309; O1-NEXT:    addiu $1, $zero, -4
5310; O1-NEXT:    and $2, $4, $1
5311; O1-NEXT:    andi $1, $4, 3
5312; O1-NEXT:    sll $3, $1, 3
5313; O1-NEXT:    ori $1, $zero, 255
5314; O1-NEXT:    sllv $4, $1, $3
5315; O1-NEXT:    nor $7, $zero, $4
5316; O1-NEXT:    andi $1, $5, 255
5317; O1-NEXT:    sllv $8, $1, $3
5318; O1-NEXT:    andi $1, $6, 255
5319; O1-NEXT:    sllv $6, $1, $3
5320; O1-NEXT:  $BB13_1: # %entry
5321; O1-NEXT:    # =>This Inner Loop Header: Depth=1
5322; O1-NEXT:    ll $9, 0($2)
5323; O1-NEXT:    and $10, $9, $4
5324; O1-NEXT:    bne $10, $8, $BB13_3
5325; O1-NEXT:    nop
5326; O1-NEXT:  # %bb.2: # %entry
5327; O1-NEXT:    # in Loop: Header=BB13_1 Depth=1
5328; O1-NEXT:    and $9, $9, $7
5329; O1-NEXT:    or $9, $9, $6
5330; O1-NEXT:    sc $9, 0($2)
5331; O1-NEXT:    beqz $9, $BB13_1
5332; O1-NEXT:    nop
5333; O1-NEXT:  $BB13_3: # %entry
5334; O1-NEXT:    srlv $1, $10, $3
5335; O1-NEXT:    sll $1, $1, 24
5336; O1-NEXT:    sra $1, $1, 24
5337; O1-NEXT:  # %bb.4: # %entry
5338; O1-NEXT:    sll $2, $5, 24
5339; O1-NEXT:    sra $2, $2, 24
5340; O1-NEXT:    xor $1, $1, $2
5341; O1-NEXT:    jr $ra
5342; O1-NEXT:    sltiu $2, $1, 1
5343;
5344; O2-LABEL: AtomicCmpSwapRes8:
5345; O2:       # %bb.0: # %entry
5346; O2-NEXT:    addiu $1, $zero, -4
5347; O2-NEXT:    and $2, $4, $1
5348; O2-NEXT:    andi $1, $4, 3
5349; O2-NEXT:    sll $3, $1, 3
5350; O2-NEXT:    ori $1, $zero, 255
5351; O2-NEXT:    sllv $4, $1, $3
5352; O2-NEXT:    nor $7, $zero, $4
5353; O2-NEXT:    andi $1, $5, 255
5354; O2-NEXT:    sllv $8, $1, $3
5355; O2-NEXT:    andi $1, $6, 255
5356; O2-NEXT:    sllv $6, $1, $3
5357; O2-NEXT:  $BB13_1: # %entry
5358; O2-NEXT:    # =>This Inner Loop Header: Depth=1
5359; O2-NEXT:    ll $9, 0($2)
5360; O2-NEXT:    and $10, $9, $4
5361; O2-NEXT:    bne $10, $8, $BB13_3
5362; O2-NEXT:    nop
5363; O2-NEXT:  # %bb.2: # %entry
5364; O2-NEXT:    # in Loop: Header=BB13_1 Depth=1
5365; O2-NEXT:    and $9, $9, $7
5366; O2-NEXT:    or $9, $9, $6
5367; O2-NEXT:    sc $9, 0($2)
5368; O2-NEXT:    beqz $9, $BB13_1
5369; O2-NEXT:    nop
5370; O2-NEXT:  $BB13_3: # %entry
5371; O2-NEXT:    srlv $1, $10, $3
5372; O2-NEXT:    sll $1, $1, 24
5373; O2-NEXT:    sra $1, $1, 24
5374; O2-NEXT:  # %bb.4: # %entry
5375; O2-NEXT:    sll $2, $5, 24
5376; O2-NEXT:    sra $2, $2, 24
5377; O2-NEXT:    xor $1, $1, $2
5378; O2-NEXT:    jr $ra
5379; O2-NEXT:    sltiu $2, $1, 1
5380;
5381; O3-LABEL: AtomicCmpSwapRes8:
5382; O3:       # %bb.0: # %entry
5383; O3-NEXT:    addiu $1, $zero, -4
5384; O3-NEXT:    and $2, $4, $1
5385; O3-NEXT:    andi $1, $4, 3
5386; O3-NEXT:    sll $3, $1, 3
5387; O3-NEXT:    ori $1, $zero, 255
5388; O3-NEXT:    sllv $4, $1, $3
5389; O3-NEXT:    andi $1, $5, 255
5390; O3-NEXT:    sllv $8, $1, $3
5391; O3-NEXT:    andi $1, $6, 255
5392; O3-NEXT:    nor $7, $zero, $4
5393; O3-NEXT:    sllv $6, $1, $3
5394; O3-NEXT:  $BB13_1: # %entry
5395; O3-NEXT:    # =>This Inner Loop Header: Depth=1
5396; O3-NEXT:    ll $9, 0($2)
5397; O3-NEXT:    and $10, $9, $4
5398; O3-NEXT:    bne $10, $8, $BB13_3
5399; O3-NEXT:    nop
5400; O3-NEXT:  # %bb.2: # %entry
5401; O3-NEXT:    # in Loop: Header=BB13_1 Depth=1
5402; O3-NEXT:    and $9, $9, $7
5403; O3-NEXT:    or $9, $9, $6
5404; O3-NEXT:    sc $9, 0($2)
5405; O3-NEXT:    beqz $9, $BB13_1
5406; O3-NEXT:    nop
5407; O3-NEXT:  $BB13_3: # %entry
5408; O3-NEXT:    srlv $1, $10, $3
5409; O3-NEXT:    sll $1, $1, 24
5410; O3-NEXT:    sra $1, $1, 24
5411; O3-NEXT:  # %bb.4: # %entry
5412; O3-NEXT:    sll $2, $5, 24
5413; O3-NEXT:    sra $2, $2, 24
5414; O3-NEXT:    xor $1, $1, $2
5415; O3-NEXT:    jr $ra
5416; O3-NEXT:    sltiu $2, $1, 1
5417;
5418; MIPS32EB-LABEL: AtomicCmpSwapRes8:
5419; MIPS32EB:       # %bb.0: # %entry
5420; MIPS32EB-NEXT:    addiu $1, $zero, -4
5421; MIPS32EB-NEXT:    and $2, $4, $1
5422; MIPS32EB-NEXT:    andi $1, $4, 3
5423; MIPS32EB-NEXT:    xori $1, $1, 3
5424; MIPS32EB-NEXT:    sll $3, $1, 3
5425; MIPS32EB-NEXT:    ori $1, $zero, 255
5426; MIPS32EB-NEXT:    sllv $4, $1, $3
5427; MIPS32EB-NEXT:    nor $7, $zero, $4
5428; MIPS32EB-NEXT:    andi $1, $5, 255
5429; MIPS32EB-NEXT:    sllv $8, $1, $3
5430; MIPS32EB-NEXT:    andi $1, $6, 255
5431; MIPS32EB-NEXT:    sllv $6, $1, $3
5432; MIPS32EB-NEXT:  $BB13_1: # %entry
5433; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
5434; MIPS32EB-NEXT:    ll $9, 0($2)
5435; MIPS32EB-NEXT:    and $10, $9, $4
5436; MIPS32EB-NEXT:    bne $10, $8, $BB13_3
5437; MIPS32EB-NEXT:    nop
5438; MIPS32EB-NEXT:  # %bb.2: # %entry
5439; MIPS32EB-NEXT:    # in Loop: Header=BB13_1 Depth=1
5440; MIPS32EB-NEXT:    and $9, $9, $7
5441; MIPS32EB-NEXT:    or $9, $9, $6
5442; MIPS32EB-NEXT:    sc $9, 0($2)
5443; MIPS32EB-NEXT:    beqz $9, $BB13_1
5444; MIPS32EB-NEXT:    nop
5445; MIPS32EB-NEXT:  $BB13_3: # %entry
5446; MIPS32EB-NEXT:    srlv $1, $10, $3
5447; MIPS32EB-NEXT:    sll $1, $1, 24
5448; MIPS32EB-NEXT:    sra $1, $1, 24
5449; MIPS32EB-NEXT:  # %bb.4: # %entry
5450; MIPS32EB-NEXT:    sll $2, $5, 24
5451; MIPS32EB-NEXT:    sra $2, $2, 24
5452; MIPS32EB-NEXT:    xor $1, $1, $2
5453; MIPS32EB-NEXT:    jr $ra
5454; MIPS32EB-NEXT:    sltiu $2, $1, 1
5455entry:
5456  %0 = cmpxchg i8* %ptr, i8 %oldval, i8 %newval monotonic monotonic
5457  %1 = extractvalue { i8, i1 } %0, 1
5458  ret i1 %1
5459; FIXME: -march=mips produces a redundant sign extension here...
5460; FIXME: ...Leading to this split check.
5461
5462}
5463
5464; Check one i16 so that we cover the seh sign extend
5465@z = common global i16 0, align 1
5466
5467define signext i16 @AtomicLoadAdd16(i16 signext %incr) nounwind {
5468; MIPS32-LABEL: AtomicLoadAdd16:
5469; MIPS32:       # %bb.0: # %entry
5470; MIPS32-NEXT:    lui $2, %hi(_gp_disp)
5471; MIPS32-NEXT:    addiu $2, $2, %lo(_gp_disp)
5472; MIPS32-NEXT:    addu $1, $2, $25
5473; MIPS32-NEXT:    lw $1, %got(z)($1)
5474; MIPS32-NEXT:    addiu $2, $zero, -4
5475; MIPS32-NEXT:    and $2, $1, $2
5476; MIPS32-NEXT:    andi $1, $1, 3
5477; MIPS32-NEXT:    sll $3, $1, 3
5478; MIPS32-NEXT:    ori $1, $zero, 65535
5479; MIPS32-NEXT:    sllv $5, $1, $3
5480; MIPS32-NEXT:    nor $6, $zero, $5
5481; MIPS32-NEXT:    sllv $4, $4, $3
5482; MIPS32-NEXT:  $BB14_1: # %entry
5483; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
5484; MIPS32-NEXT:    ll $7, 0($2)
5485; MIPS32-NEXT:    addu $8, $7, $4
5486; MIPS32-NEXT:    and $8, $8, $5
5487; MIPS32-NEXT:    and $9, $7, $6
5488; MIPS32-NEXT:    or $9, $9, $8
5489; MIPS32-NEXT:    sc $9, 0($2)
5490; MIPS32-NEXT:    beqz $9, $BB14_1
5491; MIPS32-NEXT:    nop
5492; MIPS32-NEXT:  # %bb.2: # %entry
5493; MIPS32-NEXT:    and $1, $7, $5
5494; MIPS32-NEXT:    srlv $1, $1, $3
5495; MIPS32-NEXT:    sll $1, $1, 16
5496; MIPS32-NEXT:    sra $1, $1, 16
5497; MIPS32-NEXT:  # %bb.3: # %entry
5498; MIPS32-NEXT:    sll $1, $1, 16
5499; MIPS32-NEXT:    jr $ra
5500; MIPS32-NEXT:    sra $2, $1, 16
5501;
5502; MIPS32O0-LABEL: AtomicLoadAdd16:
5503; MIPS32O0:       # %bb.0: # %entry
5504; MIPS32O0-NEXT:    lui $2, %hi(_gp_disp)
5505; MIPS32O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
5506; MIPS32O0-NEXT:    addiu $sp, $sp, -8
5507; MIPS32O0-NEXT:    addu $1, $2, $25
5508; MIPS32O0-NEXT:    lw $1, %got(z)($1)
5509; MIPS32O0-NEXT:    addiu $2, $zero, -4
5510; MIPS32O0-NEXT:    and $5, $1, $2
5511; MIPS32O0-NEXT:    andi $1, $1, 3
5512; MIPS32O0-NEXT:    sll $9, $1, 3
5513; MIPS32O0-NEXT:    ori $1, $zero, 65535
5514; MIPS32O0-NEXT:    sllv $7, $1, $9
5515; MIPS32O0-NEXT:    nor $8, $zero, $7
5516; MIPS32O0-NEXT:    sllv $6, $4, $9
5517; MIPS32O0-NEXT:  $BB14_1: # %entry
5518; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
5519; MIPS32O0-NEXT:    ll $2, 0($5)
5520; MIPS32O0-NEXT:    addu $3, $2, $6
5521; MIPS32O0-NEXT:    and $3, $3, $7
5522; MIPS32O0-NEXT:    and $4, $2, $8
5523; MIPS32O0-NEXT:    or $4, $4, $3
5524; MIPS32O0-NEXT:    sc $4, 0($5)
5525; MIPS32O0-NEXT:    beqz $4, $BB14_1
5526; MIPS32O0-NEXT:    nop
5527; MIPS32O0-NEXT:  # %bb.2: # %entry
5528; MIPS32O0-NEXT:    and $1, $2, $7
5529; MIPS32O0-NEXT:    srlv $1, $1, $9
5530; MIPS32O0-NEXT:    sll $1, $1, 16
5531; MIPS32O0-NEXT:    sra $1, $1, 16
5532; MIPS32O0-NEXT:  # %bb.3: # %entry
5533; MIPS32O0-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
5534; MIPS32O0-NEXT:  # %bb.4: # %entry
5535; MIPS32O0-NEXT:    lw $1, 4($sp) # 4-byte Folded Reload
5536; MIPS32O0-NEXT:    sll $1, $1, 16
5537; MIPS32O0-NEXT:    sra $2, $1, 16
5538; MIPS32O0-NEXT:    addiu $sp, $sp, 8
5539; MIPS32O0-NEXT:    jr $ra
5540; MIPS32O0-NEXT:    nop
5541;
5542; MIPS32R2-LABEL: AtomicLoadAdd16:
5543; MIPS32R2:       # %bb.0: # %entry
5544; MIPS32R2-NEXT:    lui $2, %hi(_gp_disp)
5545; MIPS32R2-NEXT:    addiu $2, $2, %lo(_gp_disp)
5546; MIPS32R2-NEXT:    addu $1, $2, $25
5547; MIPS32R2-NEXT:    lw $1, %got(z)($1)
5548; MIPS32R2-NEXT:    addiu $2, $zero, -4
5549; MIPS32R2-NEXT:    and $2, $1, $2
5550; MIPS32R2-NEXT:    andi $1, $1, 3
5551; MIPS32R2-NEXT:    sll $3, $1, 3
5552; MIPS32R2-NEXT:    ori $1, $zero, 65535
5553; MIPS32R2-NEXT:    sllv $5, $1, $3
5554; MIPS32R2-NEXT:    nor $6, $zero, $5
5555; MIPS32R2-NEXT:    sllv $4, $4, $3
5556; MIPS32R2-NEXT:  $BB14_1: # %entry
5557; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
5558; MIPS32R2-NEXT:    ll $7, 0($2)
5559; MIPS32R2-NEXT:    addu $8, $7, $4
5560; MIPS32R2-NEXT:    and $8, $8, $5
5561; MIPS32R2-NEXT:    and $9, $7, $6
5562; MIPS32R2-NEXT:    or $9, $9, $8
5563; MIPS32R2-NEXT:    sc $9, 0($2)
5564; MIPS32R2-NEXT:    beqz $9, $BB14_1
5565; MIPS32R2-NEXT:    nop
5566; MIPS32R2-NEXT:  # %bb.2: # %entry
5567; MIPS32R2-NEXT:    and $1, $7, $5
5568; MIPS32R2-NEXT:    srlv $1, $1, $3
5569; MIPS32R2-NEXT:    seh $1, $1
5570; MIPS32R2-NEXT:  # %bb.3: # %entry
5571; MIPS32R2-NEXT:    jr $ra
5572; MIPS32R2-NEXT:    seh $2, $1
5573;
5574; MIPS32R6-LABEL: AtomicLoadAdd16:
5575; MIPS32R6:       # %bb.0: # %entry
5576; MIPS32R6-NEXT:    lui $2, %hi(_gp_disp)
5577; MIPS32R6-NEXT:    addiu $2, $2, %lo(_gp_disp)
5578; MIPS32R6-NEXT:    addu $1, $2, $25
5579; MIPS32R6-NEXT:    lw $1, %got(z)($1)
5580; MIPS32R6-NEXT:    addiu $2, $zero, -4
5581; MIPS32R6-NEXT:    and $2, $1, $2
5582; MIPS32R6-NEXT:    andi $1, $1, 3
5583; MIPS32R6-NEXT:    sll $3, $1, 3
5584; MIPS32R6-NEXT:    ori $1, $zero, 65535
5585; MIPS32R6-NEXT:    sllv $5, $1, $3
5586; MIPS32R6-NEXT:    nor $6, $zero, $5
5587; MIPS32R6-NEXT:    sllv $4, $4, $3
5588; MIPS32R6-NEXT:  $BB14_1: # %entry
5589; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
5590; MIPS32R6-NEXT:    ll $7, 0($2)
5591; MIPS32R6-NEXT:    addu $8, $7, $4
5592; MIPS32R6-NEXT:    and $8, $8, $5
5593; MIPS32R6-NEXT:    and $9, $7, $6
5594; MIPS32R6-NEXT:    or $9, $9, $8
5595; MIPS32R6-NEXT:    sc $9, 0($2)
5596; MIPS32R6-NEXT:    beqzc $9, $BB14_1
5597; MIPS32R6-NEXT:  # %bb.2: # %entry
5598; MIPS32R6-NEXT:    and $1, $7, $5
5599; MIPS32R6-NEXT:    srlv $1, $1, $3
5600; MIPS32R6-NEXT:    seh $1, $1
5601; MIPS32R6-NEXT:  # %bb.3: # %entry
5602; MIPS32R6-NEXT:    jr $ra
5603; MIPS32R6-NEXT:    seh $2, $1
5604;
5605; MIPS32R6O0-LABEL: AtomicLoadAdd16:
5606; MIPS32R6O0:       # %bb.0: # %entry
5607; MIPS32R6O0-NEXT:    lui $2, %hi(_gp_disp)
5608; MIPS32R6O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
5609; MIPS32R6O0-NEXT:    addiu $sp, $sp, -8
5610; MIPS32R6O0-NEXT:    addu $1, $2, $25
5611; MIPS32R6O0-NEXT:    # kill: def $v0 killed $a0
5612; MIPS32R6O0-NEXT:    lw $1, %got(z)($1)
5613; MIPS32R6O0-NEXT:    addiu $2, $zero, -4
5614; MIPS32R6O0-NEXT:    and $5, $1, $2
5615; MIPS32R6O0-NEXT:    andi $1, $1, 3
5616; MIPS32R6O0-NEXT:    sll $9, $1, 3
5617; MIPS32R6O0-NEXT:    ori $1, $zero, 65535
5618; MIPS32R6O0-NEXT:    sllv $7, $1, $9
5619; MIPS32R6O0-NEXT:    nor $8, $zero, $7
5620; MIPS32R6O0-NEXT:    sllv $6, $4, $9
5621; MIPS32R6O0-NEXT:  $BB14_1: # %entry
5622; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
5623; MIPS32R6O0-NEXT:    ll $2, 0($5)
5624; MIPS32R6O0-NEXT:    addu $3, $2, $6
5625; MIPS32R6O0-NEXT:    and $3, $3, $7
5626; MIPS32R6O0-NEXT:    and $4, $2, $8
5627; MIPS32R6O0-NEXT:    or $4, $4, $3
5628; MIPS32R6O0-NEXT:    sc $4, 0($5)
5629; MIPS32R6O0-NEXT:    beqzc $4, $BB14_1
5630; MIPS32R6O0-NEXT:  # %bb.2: # %entry
5631; MIPS32R6O0-NEXT:    and $1, $2, $7
5632; MIPS32R6O0-NEXT:    srlv $1, $1, $9
5633; MIPS32R6O0-NEXT:    seh $1, $1
5634; MIPS32R6O0-NEXT:  # %bb.3: # %entry
5635; MIPS32R6O0-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
5636; MIPS32R6O0-NEXT:  # %bb.4: # %entry
5637; MIPS32R6O0-NEXT:    lw $1, 4($sp) # 4-byte Folded Reload
5638; MIPS32R6O0-NEXT:    seh $2, $1
5639; MIPS32R6O0-NEXT:    addiu $sp, $sp, 8
5640; MIPS32R6O0-NEXT:    jrc $ra
5641;
5642; MIPS4-LABEL: AtomicLoadAdd16:
5643; MIPS4:       # %bb.0: # %entry
5644; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd16)))
5645; MIPS4-NEXT:    daddu $1, $1, $25
5646; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd16)))
5647; MIPS4-NEXT:    ld $1, %got_disp(z)($1)
5648; MIPS4-NEXT:    daddiu $2, $zero, -4
5649; MIPS4-NEXT:    and $2, $1, $2
5650; MIPS4-NEXT:    andi $1, $1, 3
5651; MIPS4-NEXT:    sll $3, $1, 3
5652; MIPS4-NEXT:    ori $1, $zero, 65535
5653; MIPS4-NEXT:    sllv $5, $1, $3
5654; MIPS4-NEXT:    nor $6, $zero, $5
5655; MIPS4-NEXT:    sllv $4, $4, $3
5656; MIPS4-NEXT:  .LBB14_1: # %entry
5657; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
5658; MIPS4-NEXT:    ll $7, 0($2)
5659; MIPS4-NEXT:    addu $8, $7, $4
5660; MIPS4-NEXT:    and $8, $8, $5
5661; MIPS4-NEXT:    and $9, $7, $6
5662; MIPS4-NEXT:    or $9, $9, $8
5663; MIPS4-NEXT:    sc $9, 0($2)
5664; MIPS4-NEXT:    beqz $9, .LBB14_1
5665; MIPS4-NEXT:    nop
5666; MIPS4-NEXT:  # %bb.2: # %entry
5667; MIPS4-NEXT:    and $1, $7, $5
5668; MIPS4-NEXT:    srlv $1, $1, $3
5669; MIPS4-NEXT:    sll $1, $1, 16
5670; MIPS4-NEXT:    sra $1, $1, 16
5671; MIPS4-NEXT:  # %bb.3: # %entry
5672; MIPS4-NEXT:    sll $1, $1, 16
5673; MIPS4-NEXT:    jr $ra
5674; MIPS4-NEXT:    sra $2, $1, 16
5675;
5676; MIPS64-LABEL: AtomicLoadAdd16:
5677; MIPS64:       # %bb.0: # %entry
5678; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd16)))
5679; MIPS64-NEXT:    daddu $1, $1, $25
5680; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd16)))
5681; MIPS64-NEXT:    ld $1, %got_disp(z)($1)
5682; MIPS64-NEXT:    daddiu $2, $zero, -4
5683; MIPS64-NEXT:    and $2, $1, $2
5684; MIPS64-NEXT:    andi $1, $1, 3
5685; MIPS64-NEXT:    sll $3, $1, 3
5686; MIPS64-NEXT:    ori $1, $zero, 65535
5687; MIPS64-NEXT:    sllv $5, $1, $3
5688; MIPS64-NEXT:    nor $6, $zero, $5
5689; MIPS64-NEXT:    sllv $4, $4, $3
5690; MIPS64-NEXT:  .LBB14_1: # %entry
5691; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
5692; MIPS64-NEXT:    ll $7, 0($2)
5693; MIPS64-NEXT:    addu $8, $7, $4
5694; MIPS64-NEXT:    and $8, $8, $5
5695; MIPS64-NEXT:    and $9, $7, $6
5696; MIPS64-NEXT:    or $9, $9, $8
5697; MIPS64-NEXT:    sc $9, 0($2)
5698; MIPS64-NEXT:    beqz $9, .LBB14_1
5699; MIPS64-NEXT:    nop
5700; MIPS64-NEXT:  # %bb.2: # %entry
5701; MIPS64-NEXT:    and $1, $7, $5
5702; MIPS64-NEXT:    srlv $1, $1, $3
5703; MIPS64-NEXT:    sll $1, $1, 16
5704; MIPS64-NEXT:    sra $1, $1, 16
5705; MIPS64-NEXT:  # %bb.3: # %entry
5706; MIPS64-NEXT:    sll $1, $1, 16
5707; MIPS64-NEXT:    jr $ra
5708; MIPS64-NEXT:    sra $2, $1, 16
5709;
5710; MIPS64R2-LABEL: AtomicLoadAdd16:
5711; MIPS64R2:       # %bb.0: # %entry
5712; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd16)))
5713; MIPS64R2-NEXT:    daddu $1, $1, $25
5714; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd16)))
5715; MIPS64R2-NEXT:    ld $1, %got_disp(z)($1)
5716; MIPS64R2-NEXT:    daddiu $2, $zero, -4
5717; MIPS64R2-NEXT:    and $2, $1, $2
5718; MIPS64R2-NEXT:    andi $1, $1, 3
5719; MIPS64R2-NEXT:    sll $3, $1, 3
5720; MIPS64R2-NEXT:    ori $1, $zero, 65535
5721; MIPS64R2-NEXT:    sllv $5, $1, $3
5722; MIPS64R2-NEXT:    nor $6, $zero, $5
5723; MIPS64R2-NEXT:    sllv $4, $4, $3
5724; MIPS64R2-NEXT:  .LBB14_1: # %entry
5725; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
5726; MIPS64R2-NEXT:    ll $7, 0($2)
5727; MIPS64R2-NEXT:    addu $8, $7, $4
5728; MIPS64R2-NEXT:    and $8, $8, $5
5729; MIPS64R2-NEXT:    and $9, $7, $6
5730; MIPS64R2-NEXT:    or $9, $9, $8
5731; MIPS64R2-NEXT:    sc $9, 0($2)
5732; MIPS64R2-NEXT:    beqz $9, .LBB14_1
5733; MIPS64R2-NEXT:    nop
5734; MIPS64R2-NEXT:  # %bb.2: # %entry
5735; MIPS64R2-NEXT:    and $1, $7, $5
5736; MIPS64R2-NEXT:    srlv $1, $1, $3
5737; MIPS64R2-NEXT:    seh $1, $1
5738; MIPS64R2-NEXT:  # %bb.3: # %entry
5739; MIPS64R2-NEXT:    jr $ra
5740; MIPS64R2-NEXT:    seh $2, $1
5741;
5742; MIPS64R6-LABEL: AtomicLoadAdd16:
5743; MIPS64R6:       # %bb.0: # %entry
5744; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd16)))
5745; MIPS64R6-NEXT:    daddu $1, $1, $25
5746; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd16)))
5747; MIPS64R6-NEXT:    ld $1, %got_disp(z)($1)
5748; MIPS64R6-NEXT:    daddiu $2, $zero, -4
5749; MIPS64R6-NEXT:    and $2, $1, $2
5750; MIPS64R6-NEXT:    andi $1, $1, 3
5751; MIPS64R6-NEXT:    sll $3, $1, 3
5752; MIPS64R6-NEXT:    ori $1, $zero, 65535
5753; MIPS64R6-NEXT:    sllv $5, $1, $3
5754; MIPS64R6-NEXT:    nor $6, $zero, $5
5755; MIPS64R6-NEXT:    sllv $4, $4, $3
5756; MIPS64R6-NEXT:  .LBB14_1: # %entry
5757; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
5758; MIPS64R6-NEXT:    ll $7, 0($2)
5759; MIPS64R6-NEXT:    addu $8, $7, $4
5760; MIPS64R6-NEXT:    and $8, $8, $5
5761; MIPS64R6-NEXT:    and $9, $7, $6
5762; MIPS64R6-NEXT:    or $9, $9, $8
5763; MIPS64R6-NEXT:    sc $9, 0($2)
5764; MIPS64R6-NEXT:    beqzc $9, .LBB14_1
5765; MIPS64R6-NEXT:  # %bb.2: # %entry
5766; MIPS64R6-NEXT:    and $1, $7, $5
5767; MIPS64R6-NEXT:    srlv $1, $1, $3
5768; MIPS64R6-NEXT:    seh $1, $1
5769; MIPS64R6-NEXT:  # %bb.3: # %entry
5770; MIPS64R6-NEXT:    jr $ra
5771; MIPS64R6-NEXT:    seh $2, $1
5772;
5773; MIPS64R6O0-LABEL: AtomicLoadAdd16:
5774; MIPS64R6O0:       # %bb.0: # %entry
5775; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -16
5776; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd16)))
5777; MIPS64R6O0-NEXT:    daddu $1, $1, $25
5778; MIPS64R6O0-NEXT:    daddiu $2, $1, %lo(%neg(%gp_rel(AtomicLoadAdd16)))
5779; MIPS64R6O0-NEXT:    move $1, $4
5780; MIPS64R6O0-NEXT:    ld $2, %got_disp(z)($2)
5781; MIPS64R6O0-NEXT:    daddiu $3, $zero, -4
5782; MIPS64R6O0-NEXT:    and $5, $2, $3
5783; MIPS64R6O0-NEXT:    andi $2, $2, 3
5784; MIPS64R6O0-NEXT:    xori $2, $2, 2
5785; MIPS64R6O0-NEXT:    sll $9, $2, 3
5786; MIPS64R6O0-NEXT:    ori $2, $zero, 65535
5787; MIPS64R6O0-NEXT:    sllv $7, $2, $9
5788; MIPS64R6O0-NEXT:    nor $8, $zero, $7
5789; MIPS64R6O0-NEXT:    sllv $6, $1, $9
5790; MIPS64R6O0-NEXT:  .LBB14_1: # %entry
5791; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
5792; MIPS64R6O0-NEXT:    ll $2, 0($5)
5793; MIPS64R6O0-NEXT:    addu $3, $2, $6
5794; MIPS64R6O0-NEXT:    and $3, $3, $7
5795; MIPS64R6O0-NEXT:    and $4, $2, $8
5796; MIPS64R6O0-NEXT:    or $4, $4, $3
5797; MIPS64R6O0-NEXT:    sc $4, 0($5)
5798; MIPS64R6O0-NEXT:    beqzc $4, .LBB14_1
5799; MIPS64R6O0-NEXT:  # %bb.2: # %entry
5800; MIPS64R6O0-NEXT:    and $1, $2, $7
5801; MIPS64R6O0-NEXT:    srlv $1, $1, $9
5802; MIPS64R6O0-NEXT:    seh $1, $1
5803; MIPS64R6O0-NEXT:  # %bb.3: # %entry
5804; MIPS64R6O0-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
5805; MIPS64R6O0-NEXT:  # %bb.4: # %entry
5806; MIPS64R6O0-NEXT:    lw $1, 12($sp) # 4-byte Folded Reload
5807; MIPS64R6O0-NEXT:    seh $2, $1
5808; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 16
5809; MIPS64R6O0-NEXT:    jrc $ra
5810;
5811; MM32-LABEL: AtomicLoadAdd16:
5812; MM32:       # %bb.0: # %entry
5813; MM32-NEXT:    lui $2, %hi(_gp_disp)
5814; MM32-NEXT:    addiu $2, $2, %lo(_gp_disp)
5815; MM32-NEXT:    addu $2, $2, $25
5816; MM32-NEXT:    lw $1, %got(z)($2)
5817; MM32-NEXT:    addiu $2, $zero, -4
5818; MM32-NEXT:    and $2, $1, $2
5819; MM32-NEXT:    andi $1, $1, 3
5820; MM32-NEXT:    sll $3, $1, 3
5821; MM32-NEXT:    ori $1, $zero, 65535
5822; MM32-NEXT:    sllv $5, $1, $3
5823; MM32-NEXT:    nor $6, $zero, $5
5824; MM32-NEXT:    sllv $4, $4, $3
5825; MM32-NEXT:  $BB14_1: # %entry
5826; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
5827; MM32-NEXT:    ll $7, 0($2)
5828; MM32-NEXT:    addu $8, $7, $4
5829; MM32-NEXT:    and $8, $8, $5
5830; MM32-NEXT:    and $9, $7, $6
5831; MM32-NEXT:    or $9, $9, $8
5832; MM32-NEXT:    sc $9, 0($2)
5833; MM32-NEXT:    beqzc $9, $BB14_1
5834; MM32-NEXT:  # %bb.2: # %entry
5835; MM32-NEXT:    and $1, $7, $5
5836; MM32-NEXT:    srlv $1, $1, $3
5837; MM32-NEXT:    seh $1, $1
5838; MM32-NEXT:  # %bb.3: # %entry
5839; MM32-NEXT:    jr $ra
5840; MM32-NEXT:    seh $2, $1
5841;
5842; O1-LABEL: AtomicLoadAdd16:
5843; O1:       # %bb.0: # %entry
5844; O1-NEXT:    lui $2, %hi(_gp_disp)
5845; O1-NEXT:    addiu $2, $2, %lo(_gp_disp)
5846; O1-NEXT:    addu $1, $2, $25
5847; O1-NEXT:    lw $1, %got(z)($1)
5848; O1-NEXT:    addiu $2, $zero, -4
5849; O1-NEXT:    and $2, $1, $2
5850; O1-NEXT:    andi $1, $1, 3
5851; O1-NEXT:    sll $3, $1, 3
5852; O1-NEXT:    ori $1, $zero, 65535
5853; O1-NEXT:    sllv $5, $1, $3
5854; O1-NEXT:    nor $6, $zero, $5
5855; O1-NEXT:    sllv $4, $4, $3
5856; O1-NEXT:  $BB14_1: # %entry
5857; O1-NEXT:    # =>This Inner Loop Header: Depth=1
5858; O1-NEXT:    ll $7, 0($2)
5859; O1-NEXT:    addu $8, $7, $4
5860; O1-NEXT:    and $8, $8, $5
5861; O1-NEXT:    and $9, $7, $6
5862; O1-NEXT:    or $9, $9, $8
5863; O1-NEXT:    sc $9, 0($2)
5864; O1-NEXT:    beqz $9, $BB14_1
5865; O1-NEXT:    nop
5866; O1-NEXT:  # %bb.2: # %entry
5867; O1-NEXT:    and $1, $7, $5
5868; O1-NEXT:    srlv $1, $1, $3
5869; O1-NEXT:    sll $1, $1, 16
5870; O1-NEXT:    sra $1, $1, 16
5871; O1-NEXT:  # %bb.3: # %entry
5872; O1-NEXT:    sll $1, $1, 16
5873; O1-NEXT:    jr $ra
5874; O1-NEXT:    sra $2, $1, 16
5875;
5876; O2-LABEL: AtomicLoadAdd16:
5877; O2:       # %bb.0: # %entry
5878; O2-NEXT:    lui $2, %hi(_gp_disp)
5879; O2-NEXT:    addiu $2, $2, %lo(_gp_disp)
5880; O2-NEXT:    addu $1, $2, $25
5881; O2-NEXT:    lw $1, %got(z)($1)
5882; O2-NEXT:    addiu $2, $zero, -4
5883; O2-NEXT:    and $2, $1, $2
5884; O2-NEXT:    andi $1, $1, 3
5885; O2-NEXT:    sll $3, $1, 3
5886; O2-NEXT:    ori $1, $zero, 65535
5887; O2-NEXT:    sllv $5, $1, $3
5888; O2-NEXT:    nor $6, $zero, $5
5889; O2-NEXT:    sllv $4, $4, $3
5890; O2-NEXT:  $BB14_1: # %entry
5891; O2-NEXT:    # =>This Inner Loop Header: Depth=1
5892; O2-NEXT:    ll $7, 0($2)
5893; O2-NEXT:    addu $8, $7, $4
5894; O2-NEXT:    and $8, $8, $5
5895; O2-NEXT:    and $9, $7, $6
5896; O2-NEXT:    or $9, $9, $8
5897; O2-NEXT:    sc $9, 0($2)
5898; O2-NEXT:    beqz $9, $BB14_1
5899; O2-NEXT:    nop
5900; O2-NEXT:  # %bb.2: # %entry
5901; O2-NEXT:    and $1, $7, $5
5902; O2-NEXT:    srlv $1, $1, $3
5903; O2-NEXT:    sll $1, $1, 16
5904; O2-NEXT:    sra $1, $1, 16
5905; O2-NEXT:  # %bb.3: # %entry
5906; O2-NEXT:    sll $1, $1, 16
5907; O2-NEXT:    jr $ra
5908; O2-NEXT:    sra $2, $1, 16
5909;
5910; O3-LABEL: AtomicLoadAdd16:
5911; O3:       # %bb.0: # %entry
5912; O3-NEXT:    lui $2, %hi(_gp_disp)
5913; O3-NEXT:    addiu $2, $2, %lo(_gp_disp)
5914; O3-NEXT:    addu $1, $2, $25
5915; O3-NEXT:    addiu $2, $zero, -4
5916; O3-NEXT:    lw $1, %got(z)($1)
5917; O3-NEXT:    and $2, $1, $2
5918; O3-NEXT:    andi $1, $1, 3
5919; O3-NEXT:    sll $3, $1, 3
5920; O3-NEXT:    ori $1, $zero, 65535
5921; O3-NEXT:    sllv $5, $1, $3
5922; O3-NEXT:    sllv $4, $4, $3
5923; O3-NEXT:    nor $6, $zero, $5
5924; O3-NEXT:  $BB14_1: # %entry
5925; O3-NEXT:    # =>This Inner Loop Header: Depth=1
5926; O3-NEXT:    ll $7, 0($2)
5927; O3-NEXT:    addu $8, $7, $4
5928; O3-NEXT:    and $8, $8, $5
5929; O3-NEXT:    and $9, $7, $6
5930; O3-NEXT:    or $9, $9, $8
5931; O3-NEXT:    sc $9, 0($2)
5932; O3-NEXT:    beqz $9, $BB14_1
5933; O3-NEXT:    nop
5934; O3-NEXT:  # %bb.2: # %entry
5935; O3-NEXT:    and $1, $7, $5
5936; O3-NEXT:    srlv $1, $1, $3
5937; O3-NEXT:    sll $1, $1, 16
5938; O3-NEXT:    sra $1, $1, 16
5939; O3-NEXT:  # %bb.3: # %entry
5940; O3-NEXT:    sll $1, $1, 16
5941; O3-NEXT:    jr $ra
5942; O3-NEXT:    sra $2, $1, 16
5943;
5944; MIPS32EB-LABEL: AtomicLoadAdd16:
5945; MIPS32EB:       # %bb.0: # %entry
5946; MIPS32EB-NEXT:    lui $2, %hi(_gp_disp)
5947; MIPS32EB-NEXT:    addiu $2, $2, %lo(_gp_disp)
5948; MIPS32EB-NEXT:    addu $1, $2, $25
5949; MIPS32EB-NEXT:    lw $1, %got(z)($1)
5950; MIPS32EB-NEXT:    addiu $2, $zero, -4
5951; MIPS32EB-NEXT:    and $2, $1, $2
5952; MIPS32EB-NEXT:    andi $1, $1, 3
5953; MIPS32EB-NEXT:    xori $1, $1, 2
5954; MIPS32EB-NEXT:    sll $3, $1, 3
5955; MIPS32EB-NEXT:    ori $1, $zero, 65535
5956; MIPS32EB-NEXT:    sllv $5, $1, $3
5957; MIPS32EB-NEXT:    nor $6, $zero, $5
5958; MIPS32EB-NEXT:    sllv $4, $4, $3
5959; MIPS32EB-NEXT:  $BB14_1: # %entry
5960; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
5961; MIPS32EB-NEXT:    ll $7, 0($2)
5962; MIPS32EB-NEXT:    addu $8, $7, $4
5963; MIPS32EB-NEXT:    and $8, $8, $5
5964; MIPS32EB-NEXT:    and $9, $7, $6
5965; MIPS32EB-NEXT:    or $9, $9, $8
5966; MIPS32EB-NEXT:    sc $9, 0($2)
5967; MIPS32EB-NEXT:    beqz $9, $BB14_1
5968; MIPS32EB-NEXT:    nop
5969; MIPS32EB-NEXT:  # %bb.2: # %entry
5970; MIPS32EB-NEXT:    and $1, $7, $5
5971; MIPS32EB-NEXT:    srlv $1, $1, $3
5972; MIPS32EB-NEXT:    sll $1, $1, 16
5973; MIPS32EB-NEXT:    sra $1, $1, 16
5974; MIPS32EB-NEXT:  # %bb.3: # %entry
5975; MIPS32EB-NEXT:    sll $1, $1, 16
5976; MIPS32EB-NEXT:    jr $ra
5977; MIPS32EB-NEXT:    sra $2, $1, 16
5978entry:
5979  %0 = atomicrmw add i16* @z, i16 %incr monotonic
5980  ret i16 %0
5981
5982}
5983
5984; Test that the i16 return value from cmpxchg is recognised as signed,
5985; so that setCC doesn't end up comparing an unsigned value to a signed
5986; value.
5987; The rest of the functions here are testing the atomic expansion, so
5988; we just match the end of the function.
5989define {i16, i1} @foo(i16* %addr, i16 %l, i16 %r, i16 %new) {
5990; MIPS32-LABEL: foo:
5991; MIPS32:       # %bb.0:
5992; MIPS32-NEXT:    addu $1, $5, $6
5993; MIPS32-NEXT:    sync
5994; MIPS32-NEXT:    addiu $2, $zero, -4
5995; MIPS32-NEXT:    and $3, $4, $2
5996; MIPS32-NEXT:    andi $2, $4, 3
5997; MIPS32-NEXT:    sll $4, $2, 3
5998; MIPS32-NEXT:    ori $2, $zero, 65535
5999; MIPS32-NEXT:    sllv $5, $2, $4
6000; MIPS32-NEXT:    nor $6, $zero, $5
6001; MIPS32-NEXT:    andi $2, $1, 65535
6002; MIPS32-NEXT:    sllv $8, $2, $4
6003; MIPS32-NEXT:    andi $2, $7, 65535
6004; MIPS32-NEXT:    sllv $7, $2, $4
6005; MIPS32-NEXT:  $BB15_1: # =>This Inner Loop Header: Depth=1
6006; MIPS32-NEXT:    ll $9, 0($3)
6007; MIPS32-NEXT:    and $10, $9, $5
6008; MIPS32-NEXT:    bne $10, $8, $BB15_3
6009; MIPS32-NEXT:    nop
6010; MIPS32-NEXT:  # %bb.2: # in Loop: Header=BB15_1 Depth=1
6011; MIPS32-NEXT:    and $9, $9, $6
6012; MIPS32-NEXT:    or $9, $9, $7
6013; MIPS32-NEXT:    sc $9, 0($3)
6014; MIPS32-NEXT:    beqz $9, $BB15_1
6015; MIPS32-NEXT:    nop
6016; MIPS32-NEXT:  $BB15_3:
6017; MIPS32-NEXT:    srlv $2, $10, $4
6018; MIPS32-NEXT:    sll $2, $2, 16
6019; MIPS32-NEXT:    sra $2, $2, 16
6020; MIPS32-NEXT:  # %bb.4:
6021; MIPS32-NEXT:    sll $1, $1, 16
6022; MIPS32-NEXT:    sra $1, $1, 16
6023; MIPS32-NEXT:    xor $1, $2, $1
6024; MIPS32-NEXT:    sltiu $3, $1, 1
6025; MIPS32-NEXT:    sync
6026; MIPS32-NEXT:    jr $ra
6027; MIPS32-NEXT:    nop
6028;
6029; MIPS32O0-LABEL: foo:
6030; MIPS32O0:       # %bb.0:
6031; MIPS32O0-NEXT:    addiu $sp, $sp, -8
6032; MIPS32O0-NEXT:    .cfi_def_cfa_offset 8
6033; MIPS32O0-NEXT:    move $1, $7
6034; MIPS32O0-NEXT:    move $3, $4
6035; MIPS32O0-NEXT:    addu $2, $5, $6
6036; MIPS32O0-NEXT:    sw $2, 0($sp) # 4-byte Folded Spill
6037; MIPS32O0-NEXT:    sync
6038; MIPS32O0-NEXT:    addiu $4, $zero, -4
6039; MIPS32O0-NEXT:    and $4, $3, $4
6040; MIPS32O0-NEXT:    andi $3, $3, 3
6041; MIPS32O0-NEXT:    sll $9, $3, 3
6042; MIPS32O0-NEXT:    ori $3, $zero, 65535
6043; MIPS32O0-NEXT:    sllv $5, $3, $9
6044; MIPS32O0-NEXT:    nor $7, $zero, $5
6045; MIPS32O0-NEXT:    andi $2, $2, 65535
6046; MIPS32O0-NEXT:    sllv $6, $2, $9
6047; MIPS32O0-NEXT:    andi $1, $1, 65535
6048; MIPS32O0-NEXT:    sllv $8, $1, $9
6049; MIPS32O0-NEXT:  $BB15_1: # =>This Inner Loop Header: Depth=1
6050; MIPS32O0-NEXT:    ll $2, 0($4)
6051; MIPS32O0-NEXT:    and $3, $2, $5
6052; MIPS32O0-NEXT:    bne $3, $6, $BB15_3
6053; MIPS32O0-NEXT:    nop
6054; MIPS32O0-NEXT:  # %bb.2: # in Loop: Header=BB15_1 Depth=1
6055; MIPS32O0-NEXT:    and $2, $2, $7
6056; MIPS32O0-NEXT:    or $2, $2, $8
6057; MIPS32O0-NEXT:    sc $2, 0($4)
6058; MIPS32O0-NEXT:    beqz $2, $BB15_1
6059; MIPS32O0-NEXT:    nop
6060; MIPS32O0-NEXT:  $BB15_3:
6061; MIPS32O0-NEXT:    srlv $1, $3, $9
6062; MIPS32O0-NEXT:    sll $1, $1, 16
6063; MIPS32O0-NEXT:    sra $1, $1, 16
6064; MIPS32O0-NEXT:  # %bb.4:
6065; MIPS32O0-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
6066; MIPS32O0-NEXT:  # %bb.5:
6067; MIPS32O0-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
6068; MIPS32O0-NEXT:    lw $1, 0($sp) # 4-byte Folded Reload
6069; MIPS32O0-NEXT:    sll $1, $1, 16
6070; MIPS32O0-NEXT:    sra $1, $1, 16
6071; MIPS32O0-NEXT:    xor $1, $2, $1
6072; MIPS32O0-NEXT:    sltiu $3, $1, 1
6073; MIPS32O0-NEXT:    sync
6074; MIPS32O0-NEXT:    addiu $sp, $sp, 8
6075; MIPS32O0-NEXT:    jr $ra
6076; MIPS32O0-NEXT:    nop
6077;
6078; MIPS32R2-LABEL: foo:
6079; MIPS32R2:       # %bb.0:
6080; MIPS32R2-NEXT:    addu $1, $5, $6
6081; MIPS32R2-NEXT:    sync
6082; MIPS32R2-NEXT:    addiu $2, $zero, -4
6083; MIPS32R2-NEXT:    and $3, $4, $2
6084; MIPS32R2-NEXT:    andi $2, $4, 3
6085; MIPS32R2-NEXT:    sll $4, $2, 3
6086; MIPS32R2-NEXT:    ori $2, $zero, 65535
6087; MIPS32R2-NEXT:    sllv $5, $2, $4
6088; MIPS32R2-NEXT:    nor $6, $zero, $5
6089; MIPS32R2-NEXT:    andi $2, $1, 65535
6090; MIPS32R2-NEXT:    sllv $8, $2, $4
6091; MIPS32R2-NEXT:    andi $2, $7, 65535
6092; MIPS32R2-NEXT:    sllv $7, $2, $4
6093; MIPS32R2-NEXT:  $BB15_1: # =>This Inner Loop Header: Depth=1
6094; MIPS32R2-NEXT:    ll $9, 0($3)
6095; MIPS32R2-NEXT:    and $10, $9, $5
6096; MIPS32R2-NEXT:    bne $10, $8, $BB15_3
6097; MIPS32R2-NEXT:    nop
6098; MIPS32R2-NEXT:  # %bb.2: # in Loop: Header=BB15_1 Depth=1
6099; MIPS32R2-NEXT:    and $9, $9, $6
6100; MIPS32R2-NEXT:    or $9, $9, $7
6101; MIPS32R2-NEXT:    sc $9, 0($3)
6102; MIPS32R2-NEXT:    beqz $9, $BB15_1
6103; MIPS32R2-NEXT:    nop
6104; MIPS32R2-NEXT:  $BB15_3:
6105; MIPS32R2-NEXT:    srlv $2, $10, $4
6106; MIPS32R2-NEXT:    seh $2, $2
6107; MIPS32R2-NEXT:  # %bb.4:
6108; MIPS32R2-NEXT:    seh $1, $1
6109; MIPS32R2-NEXT:    xor $1, $2, $1
6110; MIPS32R2-NEXT:    sltiu $3, $1, 1
6111; MIPS32R2-NEXT:    sync
6112; MIPS32R2-NEXT:    jr $ra
6113; MIPS32R2-NEXT:    nop
6114;
6115; MIPS32R6-LABEL: foo:
6116; MIPS32R6:       # %bb.0:
6117; MIPS32R6-NEXT:    addu $1, $5, $6
6118; MIPS32R6-NEXT:    sync
6119; MIPS32R6-NEXT:    addiu $2, $zero, -4
6120; MIPS32R6-NEXT:    and $3, $4, $2
6121; MIPS32R6-NEXT:    andi $2, $4, 3
6122; MIPS32R6-NEXT:    sll $4, $2, 3
6123; MIPS32R6-NEXT:    ori $2, $zero, 65535
6124; MIPS32R6-NEXT:    sllv $5, $2, $4
6125; MIPS32R6-NEXT:    nor $6, $zero, $5
6126; MIPS32R6-NEXT:    andi $2, $1, 65535
6127; MIPS32R6-NEXT:    sllv $8, $2, $4
6128; MIPS32R6-NEXT:    andi $2, $7, 65535
6129; MIPS32R6-NEXT:    sllv $7, $2, $4
6130; MIPS32R6-NEXT:  $BB15_1: # =>This Inner Loop Header: Depth=1
6131; MIPS32R6-NEXT:    ll $9, 0($3)
6132; MIPS32R6-NEXT:    and $10, $9, $5
6133; MIPS32R6-NEXT:    bnec $10, $8, $BB15_3
6134; MIPS32R6-NEXT:  # %bb.2: # in Loop: Header=BB15_1 Depth=1
6135; MIPS32R6-NEXT:    and $9, $9, $6
6136; MIPS32R6-NEXT:    or $9, $9, $7
6137; MIPS32R6-NEXT:    sc $9, 0($3)
6138; MIPS32R6-NEXT:    beqzc $9, $BB15_1
6139; MIPS32R6-NEXT:  $BB15_3:
6140; MIPS32R6-NEXT:    srlv $2, $10, $4
6141; MIPS32R6-NEXT:    seh $2, $2
6142; MIPS32R6-NEXT:  # %bb.4:
6143; MIPS32R6-NEXT:    seh $1, $1
6144; MIPS32R6-NEXT:    xor $1, $2, $1
6145; MIPS32R6-NEXT:    sltiu $3, $1, 1
6146; MIPS32R6-NEXT:    sync
6147; MIPS32R6-NEXT:    jrc $ra
6148;
6149; MIPS32R6O0-LABEL: foo:
6150; MIPS32R6O0:       # %bb.0:
6151; MIPS32R6O0-NEXT:    addiu $sp, $sp, -8
6152; MIPS32R6O0-NEXT:    .cfi_def_cfa_offset 8
6153; MIPS32R6O0-NEXT:    move $1, $7
6154; MIPS32R6O0-NEXT:    move $3, $4
6155; MIPS32R6O0-NEXT:    # kill: def $a3 killed $at
6156; MIPS32R6O0-NEXT:    # kill: def $v0 killed $a2
6157; MIPS32R6O0-NEXT:    # kill: def $v0 killed $a1
6158; MIPS32R6O0-NEXT:    addu $2, $5, $6
6159; MIPS32R6O0-NEXT:    sw $2, 0($sp) # 4-byte Folded Spill
6160; MIPS32R6O0-NEXT:    sync
6161; MIPS32R6O0-NEXT:    addiu $4, $zero, -4
6162; MIPS32R6O0-NEXT:    and $4, $3, $4
6163; MIPS32R6O0-NEXT:    andi $3, $3, 3
6164; MIPS32R6O0-NEXT:    sll $9, $3, 3
6165; MIPS32R6O0-NEXT:    ori $3, $zero, 65535
6166; MIPS32R6O0-NEXT:    sllv $5, $3, $9
6167; MIPS32R6O0-NEXT:    nor $7, $zero, $5
6168; MIPS32R6O0-NEXT:    andi $2, $2, 65535
6169; MIPS32R6O0-NEXT:    sllv $6, $2, $9
6170; MIPS32R6O0-NEXT:    andi $1, $1, 65535
6171; MIPS32R6O0-NEXT:    sllv $8, $1, $9
6172; MIPS32R6O0-NEXT:  $BB15_1: # =>This Inner Loop Header: Depth=1
6173; MIPS32R6O0-NEXT:    ll $2, 0($4)
6174; MIPS32R6O0-NEXT:    and $3, $2, $5
6175; MIPS32R6O0-NEXT:    bnec $3, $6, $BB15_3
6176; MIPS32R6O0-NEXT:  # %bb.2: # in Loop: Header=BB15_1 Depth=1
6177; MIPS32R6O0-NEXT:    and $2, $2, $7
6178; MIPS32R6O0-NEXT:    or $2, $2, $8
6179; MIPS32R6O0-NEXT:    sc $2, 0($4)
6180; MIPS32R6O0-NEXT:    beqzc $2, $BB15_1
6181; MIPS32R6O0-NEXT:  $BB15_3:
6182; MIPS32R6O0-NEXT:    srlv $1, $3, $9
6183; MIPS32R6O0-NEXT:    seh $1, $1
6184; MIPS32R6O0-NEXT:  # %bb.4:
6185; MIPS32R6O0-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
6186; MIPS32R6O0-NEXT:  # %bb.5:
6187; MIPS32R6O0-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
6188; MIPS32R6O0-NEXT:    lw $1, 0($sp) # 4-byte Folded Reload
6189; MIPS32R6O0-NEXT:    seh $1, $1
6190; MIPS32R6O0-NEXT:    xor $1, $2, $1
6191; MIPS32R6O0-NEXT:    sltiu $3, $1, 1
6192; MIPS32R6O0-NEXT:    sync
6193; MIPS32R6O0-NEXT:    addiu $sp, $sp, 8
6194; MIPS32R6O0-NEXT:    jrc $ra
6195;
6196; MIPS4-LABEL: foo:
6197; MIPS4:       # %bb.0:
6198; MIPS4-NEXT:    sll $1, $6, 0
6199; MIPS4-NEXT:    sll $2, $5, 0
6200; MIPS4-NEXT:    addu $1, $2, $1
6201; MIPS4-NEXT:    sync
6202; MIPS4-NEXT:    sll $2, $7, 0
6203; MIPS4-NEXT:    daddiu $3, $zero, -4
6204; MIPS4-NEXT:    and $3, $4, $3
6205; MIPS4-NEXT:    andi $4, $4, 3
6206; MIPS4-NEXT:    sll $4, $4, 3
6207; MIPS4-NEXT:    ori $5, $zero, 65535
6208; MIPS4-NEXT:    sllv $5, $5, $4
6209; MIPS4-NEXT:    nor $6, $zero, $5
6210; MIPS4-NEXT:    andi $7, $1, 65535
6211; MIPS4-NEXT:    sllv $7, $7, $4
6212; MIPS4-NEXT:    andi $2, $2, 65535
6213; MIPS4-NEXT:    sllv $8, $2, $4
6214; MIPS4-NEXT:  .LBB15_1: # =>This Inner Loop Header: Depth=1
6215; MIPS4-NEXT:    ll $9, 0($3)
6216; MIPS4-NEXT:    and $10, $9, $5
6217; MIPS4-NEXT:    bne $10, $7, .LBB15_3
6218; MIPS4-NEXT:    nop
6219; MIPS4-NEXT:  # %bb.2: # in Loop: Header=BB15_1 Depth=1
6220; MIPS4-NEXT:    and $9, $9, $6
6221; MIPS4-NEXT:    or $9, $9, $8
6222; MIPS4-NEXT:    sc $9, 0($3)
6223; MIPS4-NEXT:    beqz $9, .LBB15_1
6224; MIPS4-NEXT:    nop
6225; MIPS4-NEXT:  .LBB15_3:
6226; MIPS4-NEXT:    srlv $2, $10, $4
6227; MIPS4-NEXT:    sll $2, $2, 16
6228; MIPS4-NEXT:    sra $2, $2, 16
6229; MIPS4-NEXT:  # %bb.4:
6230; MIPS4-NEXT:    sll $1, $1, 16
6231; MIPS4-NEXT:    sra $1, $1, 16
6232; MIPS4-NEXT:    xor $1, $2, $1
6233; MIPS4-NEXT:    sltiu $3, $1, 1
6234; MIPS4-NEXT:    sync
6235; MIPS4-NEXT:    jr $ra
6236; MIPS4-NEXT:    nop
6237;
6238; MIPS64-LABEL: foo:
6239; MIPS64:       # %bb.0:
6240; MIPS64-NEXT:    sll $1, $6, 0
6241; MIPS64-NEXT:    sll $2, $5, 0
6242; MIPS64-NEXT:    addu $1, $2, $1
6243; MIPS64-NEXT:    sync
6244; MIPS64-NEXT:    sll $2, $7, 0
6245; MIPS64-NEXT:    daddiu $3, $zero, -4
6246; MIPS64-NEXT:    and $3, $4, $3
6247; MIPS64-NEXT:    andi $4, $4, 3
6248; MIPS64-NEXT:    sll $4, $4, 3
6249; MIPS64-NEXT:    ori $5, $zero, 65535
6250; MIPS64-NEXT:    sllv $5, $5, $4
6251; MIPS64-NEXT:    nor $6, $zero, $5
6252; MIPS64-NEXT:    andi $7, $1, 65535
6253; MIPS64-NEXT:    sllv $7, $7, $4
6254; MIPS64-NEXT:    andi $2, $2, 65535
6255; MIPS64-NEXT:    sllv $8, $2, $4
6256; MIPS64-NEXT:  .LBB15_1: # =>This Inner Loop Header: Depth=1
6257; MIPS64-NEXT:    ll $9, 0($3)
6258; MIPS64-NEXT:    and $10, $9, $5
6259; MIPS64-NEXT:    bne $10, $7, .LBB15_3
6260; MIPS64-NEXT:    nop
6261; MIPS64-NEXT:  # %bb.2: # in Loop: Header=BB15_1 Depth=1
6262; MIPS64-NEXT:    and $9, $9, $6
6263; MIPS64-NEXT:    or $9, $9, $8
6264; MIPS64-NEXT:    sc $9, 0($3)
6265; MIPS64-NEXT:    beqz $9, .LBB15_1
6266; MIPS64-NEXT:    nop
6267; MIPS64-NEXT:  .LBB15_3:
6268; MIPS64-NEXT:    srlv $2, $10, $4
6269; MIPS64-NEXT:    sll $2, $2, 16
6270; MIPS64-NEXT:    sra $2, $2, 16
6271; MIPS64-NEXT:  # %bb.4:
6272; MIPS64-NEXT:    sll $1, $1, 16
6273; MIPS64-NEXT:    sra $1, $1, 16
6274; MIPS64-NEXT:    xor $1, $2, $1
6275; MIPS64-NEXT:    sltiu $3, $1, 1
6276; MIPS64-NEXT:    sync
6277; MIPS64-NEXT:    jr $ra
6278; MIPS64-NEXT:    nop
6279;
6280; MIPS64R2-LABEL: foo:
6281; MIPS64R2:       # %bb.0:
6282; MIPS64R2-NEXT:    sll $1, $6, 0
6283; MIPS64R2-NEXT:    sll $2, $5, 0
6284; MIPS64R2-NEXT:    addu $1, $2, $1
6285; MIPS64R2-NEXT:    sync
6286; MIPS64R2-NEXT:    sll $2, $7, 0
6287; MIPS64R2-NEXT:    daddiu $3, $zero, -4
6288; MIPS64R2-NEXT:    and $3, $4, $3
6289; MIPS64R2-NEXT:    andi $4, $4, 3
6290; MIPS64R2-NEXT:    sll $4, $4, 3
6291; MIPS64R2-NEXT:    ori $5, $zero, 65535
6292; MIPS64R2-NEXT:    sllv $5, $5, $4
6293; MIPS64R2-NEXT:    nor $6, $zero, $5
6294; MIPS64R2-NEXT:    andi $7, $1, 65535
6295; MIPS64R2-NEXT:    sllv $7, $7, $4
6296; MIPS64R2-NEXT:    andi $2, $2, 65535
6297; MIPS64R2-NEXT:    sllv $8, $2, $4
6298; MIPS64R2-NEXT:  .LBB15_1: # =>This Inner Loop Header: Depth=1
6299; MIPS64R2-NEXT:    ll $9, 0($3)
6300; MIPS64R2-NEXT:    and $10, $9, $5
6301; MIPS64R2-NEXT:    bne $10, $7, .LBB15_3
6302; MIPS64R2-NEXT:    nop
6303; MIPS64R2-NEXT:  # %bb.2: # in Loop: Header=BB15_1 Depth=1
6304; MIPS64R2-NEXT:    and $9, $9, $6
6305; MIPS64R2-NEXT:    or $9, $9, $8
6306; MIPS64R2-NEXT:    sc $9, 0($3)
6307; MIPS64R2-NEXT:    beqz $9, .LBB15_1
6308; MIPS64R2-NEXT:    nop
6309; MIPS64R2-NEXT:  .LBB15_3:
6310; MIPS64R2-NEXT:    srlv $2, $10, $4
6311; MIPS64R2-NEXT:    seh $2, $2
6312; MIPS64R2-NEXT:  # %bb.4:
6313; MIPS64R2-NEXT:    seh $1, $1
6314; MIPS64R2-NEXT:    xor $1, $2, $1
6315; MIPS64R2-NEXT:    sltiu $3, $1, 1
6316; MIPS64R2-NEXT:    sync
6317; MIPS64R2-NEXT:    jr $ra
6318; MIPS64R2-NEXT:    nop
6319;
6320; MIPS64R6-LABEL: foo:
6321; MIPS64R6:       # %bb.0:
6322; MIPS64R6-NEXT:    sll $1, $6, 0
6323; MIPS64R6-NEXT:    sll $2, $5, 0
6324; MIPS64R6-NEXT:    addu $1, $2, $1
6325; MIPS64R6-NEXT:    sync
6326; MIPS64R6-NEXT:    sll $2, $7, 0
6327; MIPS64R6-NEXT:    daddiu $3, $zero, -4
6328; MIPS64R6-NEXT:    and $3, $4, $3
6329; MIPS64R6-NEXT:    andi $4, $4, 3
6330; MIPS64R6-NEXT:    sll $4, $4, 3
6331; MIPS64R6-NEXT:    ori $5, $zero, 65535
6332; MIPS64R6-NEXT:    sllv $5, $5, $4
6333; MIPS64R6-NEXT:    nor $6, $zero, $5
6334; MIPS64R6-NEXT:    andi $7, $1, 65535
6335; MIPS64R6-NEXT:    sllv $7, $7, $4
6336; MIPS64R6-NEXT:    andi $2, $2, 65535
6337; MIPS64R6-NEXT:    sllv $8, $2, $4
6338; MIPS64R6-NEXT:  .LBB15_1: # =>This Inner Loop Header: Depth=1
6339; MIPS64R6-NEXT:    ll $9, 0($3)
6340; MIPS64R6-NEXT:    and $10, $9, $5
6341; MIPS64R6-NEXT:    bnec $10, $7, .LBB15_3
6342; MIPS64R6-NEXT:  # %bb.2: # in Loop: Header=BB15_1 Depth=1
6343; MIPS64R6-NEXT:    and $9, $9, $6
6344; MIPS64R6-NEXT:    or $9, $9, $8
6345; MIPS64R6-NEXT:    sc $9, 0($3)
6346; MIPS64R6-NEXT:    beqzc $9, .LBB15_1
6347; MIPS64R6-NEXT:  .LBB15_3:
6348; MIPS64R6-NEXT:    srlv $2, $10, $4
6349; MIPS64R6-NEXT:    seh $2, $2
6350; MIPS64R6-NEXT:  # %bb.4:
6351; MIPS64R6-NEXT:    seh $1, $1
6352; MIPS64R6-NEXT:    xor $1, $2, $1
6353; MIPS64R6-NEXT:    sltiu $3, $1, 1
6354; MIPS64R6-NEXT:    sync
6355; MIPS64R6-NEXT:    jrc $ra
6356;
6357; MIPS64R6O0-LABEL: foo:
6358; MIPS64R6O0:       # %bb.0:
6359; MIPS64R6O0-NEXT:    daddiu $sp, $sp, -16
6360; MIPS64R6O0-NEXT:    .cfi_def_cfa_offset 16
6361; MIPS64R6O0-NEXT:    move $3, $4
6362; MIPS64R6O0-NEXT:    move $1, $7
6363; MIPS64R6O0-NEXT:    sll $1, $1, 0
6364; MIPS64R6O0-NEXT:    move $2, $6
6365; MIPS64R6O0-NEXT:    sll $4, $2, 0
6366; MIPS64R6O0-NEXT:    move $2, $5
6367; MIPS64R6O0-NEXT:    sll $2, $2, 0
6368; MIPS64R6O0-NEXT:    addu $2, $2, $4
6369; MIPS64R6O0-NEXT:    sw $2, 8($sp) # 4-byte Folded Spill
6370; MIPS64R6O0-NEXT:    sync
6371; MIPS64R6O0-NEXT:    daddiu $4, $zero, -4
6372; MIPS64R6O0-NEXT:    and $4, $3, $4
6373; MIPS64R6O0-NEXT:    andi $3, $3, 3
6374; MIPS64R6O0-NEXT:    xori $3, $3, 2
6375; MIPS64R6O0-NEXT:    sll $9, $3, 3
6376; MIPS64R6O0-NEXT:    ori $3, $zero, 65535
6377; MIPS64R6O0-NEXT:    sllv $5, $3, $9
6378; MIPS64R6O0-NEXT:    nor $7, $zero, $5
6379; MIPS64R6O0-NEXT:    andi $2, $2, 65535
6380; MIPS64R6O0-NEXT:    sllv $6, $2, $9
6381; MIPS64R6O0-NEXT:    andi $1, $1, 65535
6382; MIPS64R6O0-NEXT:    sllv $8, $1, $9
6383; MIPS64R6O0-NEXT:  .LBB15_1: # =>This Inner Loop Header: Depth=1
6384; MIPS64R6O0-NEXT:    ll $2, 0($4)
6385; MIPS64R6O0-NEXT:    and $3, $2, $5
6386; MIPS64R6O0-NEXT:    bnec $3, $6, .LBB15_3
6387; MIPS64R6O0-NEXT:  # %bb.2: # in Loop: Header=BB15_1 Depth=1
6388; MIPS64R6O0-NEXT:    and $2, $2, $7
6389; MIPS64R6O0-NEXT:    or $2, $2, $8
6390; MIPS64R6O0-NEXT:    sc $2, 0($4)
6391; MIPS64R6O0-NEXT:    beqzc $2, .LBB15_1
6392; MIPS64R6O0-NEXT:  .LBB15_3:
6393; MIPS64R6O0-NEXT:    srlv $1, $3, $9
6394; MIPS64R6O0-NEXT:    seh $1, $1
6395; MIPS64R6O0-NEXT:  # %bb.4:
6396; MIPS64R6O0-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
6397; MIPS64R6O0-NEXT:  # %bb.5:
6398; MIPS64R6O0-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
6399; MIPS64R6O0-NEXT:    lw $1, 8($sp) # 4-byte Folded Reload
6400; MIPS64R6O0-NEXT:    seh $1, $1
6401; MIPS64R6O0-NEXT:    xor $1, $2, $1
6402; MIPS64R6O0-NEXT:    sltiu $3, $1, 1
6403; MIPS64R6O0-NEXT:    sync
6404; MIPS64R6O0-NEXT:    daddiu $sp, $sp, 16
6405; MIPS64R6O0-NEXT:    jrc $ra
6406;
6407; MM32-LABEL: foo:
6408; MM32:       # %bb.0:
6409; MM32-NEXT:    addu16 $3, $5, $6
6410; MM32-NEXT:    sync
6411; MM32-NEXT:    addiu $1, $zero, -4
6412; MM32-NEXT:    and $1, $4, $1
6413; MM32-NEXT:    andi $2, $4, 3
6414; MM32-NEXT:    sll $4, $2, 3
6415; MM32-NEXT:    ori $2, $zero, 65535
6416; MM32-NEXT:    sllv $5, $2, $4
6417; MM32-NEXT:    nor $6, $zero, $5
6418; MM32-NEXT:    andi $2, $3, 65535
6419; MM32-NEXT:    sllv $8, $2, $4
6420; MM32-NEXT:    andi $2, $7, 65535
6421; MM32-NEXT:    sllv $7, $2, $4
6422; MM32-NEXT:  $BB15_1: # =>This Inner Loop Header: Depth=1
6423; MM32-NEXT:    ll $9, 0($1)
6424; MM32-NEXT:    and $10, $9, $5
6425; MM32-NEXT:    bne $10, $8, $BB15_3
6426; MM32-NEXT:    nop
6427; MM32-NEXT:  # %bb.2: # in Loop: Header=BB15_1 Depth=1
6428; MM32-NEXT:    and $9, $9, $6
6429; MM32-NEXT:    or $9, $9, $7
6430; MM32-NEXT:    sc $9, 0($1)
6431; MM32-NEXT:    beqzc $9, $BB15_1
6432; MM32-NEXT:  $BB15_3:
6433; MM32-NEXT:    srlv $2, $10, $4
6434; MM32-NEXT:    seh $2, $2
6435; MM32-NEXT:  # %bb.4:
6436; MM32-NEXT:    seh $1, $3
6437; MM32-NEXT:    xor $1, $2, $1
6438; MM32-NEXT:    sltiu $3, $1, 1
6439; MM32-NEXT:    sync
6440; MM32-NEXT:    jrc $ra
6441;
6442; O1-LABEL: foo:
6443; O1:       # %bb.0:
6444; O1-NEXT:    addu $1, $5, $6
6445; O1-NEXT:    sync
6446; O1-NEXT:    addiu $2, $zero, -4
6447; O1-NEXT:    and $3, $4, $2
6448; O1-NEXT:    andi $2, $4, 3
6449; O1-NEXT:    sll $4, $2, 3
6450; O1-NEXT:    ori $2, $zero, 65535
6451; O1-NEXT:    sllv $5, $2, $4
6452; O1-NEXT:    nor $6, $zero, $5
6453; O1-NEXT:    andi $2, $1, 65535
6454; O1-NEXT:    sllv $8, $2, $4
6455; O1-NEXT:    andi $2, $7, 65535
6456; O1-NEXT:    sllv $7, $2, $4
6457; O1-NEXT:  $BB15_1: # =>This Inner Loop Header: Depth=1
6458; O1-NEXT:    ll $9, 0($3)
6459; O1-NEXT:    and $10, $9, $5
6460; O1-NEXT:    bne $10, $8, $BB15_3
6461; O1-NEXT:    nop
6462; O1-NEXT:  # %bb.2: # in Loop: Header=BB15_1 Depth=1
6463; O1-NEXT:    and $9, $9, $6
6464; O1-NEXT:    or $9, $9, $7
6465; O1-NEXT:    sc $9, 0($3)
6466; O1-NEXT:    beqz $9, $BB15_1
6467; O1-NEXT:    nop
6468; O1-NEXT:  $BB15_3:
6469; O1-NEXT:    srlv $2, $10, $4
6470; O1-NEXT:    sll $2, $2, 16
6471; O1-NEXT:    sra $2, $2, 16
6472; O1-NEXT:  # %bb.4:
6473; O1-NEXT:    sll $1, $1, 16
6474; O1-NEXT:    sra $1, $1, 16
6475; O1-NEXT:    xor $1, $2, $1
6476; O1-NEXT:    sltiu $3, $1, 1
6477; O1-NEXT:    sync
6478; O1-NEXT:    jr $ra
6479; O1-NEXT:    nop
6480;
6481; O2-LABEL: foo:
6482; O2:       # %bb.0:
6483; O2-NEXT:    addu $1, $5, $6
6484; O2-NEXT:    sync
6485; O2-NEXT:    addiu $2, $zero, -4
6486; O2-NEXT:    and $3, $4, $2
6487; O2-NEXT:    andi $2, $4, 3
6488; O2-NEXT:    sll $4, $2, 3
6489; O2-NEXT:    ori $2, $zero, 65535
6490; O2-NEXT:    sllv $5, $2, $4
6491; O2-NEXT:    nor $6, $zero, $5
6492; O2-NEXT:    andi $2, $1, 65535
6493; O2-NEXT:    sllv $8, $2, $4
6494; O2-NEXT:    andi $2, $7, 65535
6495; O2-NEXT:    sllv $7, $2, $4
6496; O2-NEXT:  $BB15_1: # =>This Inner Loop Header: Depth=1
6497; O2-NEXT:    ll $9, 0($3)
6498; O2-NEXT:    and $10, $9, $5
6499; O2-NEXT:    bne $10, $8, $BB15_3
6500; O2-NEXT:    nop
6501; O2-NEXT:  # %bb.2: # in Loop: Header=BB15_1 Depth=1
6502; O2-NEXT:    and $9, $9, $6
6503; O2-NEXT:    or $9, $9, $7
6504; O2-NEXT:    sc $9, 0($3)
6505; O2-NEXT:    beqz $9, $BB15_1
6506; O2-NEXT:    nop
6507; O2-NEXT:  $BB15_3:
6508; O2-NEXT:    srlv $2, $10, $4
6509; O2-NEXT:    sll $2, $2, 16
6510; O2-NEXT:    sra $2, $2, 16
6511; O2-NEXT:  # %bb.4:
6512; O2-NEXT:    sll $1, $1, 16
6513; O2-NEXT:    sra $1, $1, 16
6514; O2-NEXT:    xor $1, $2, $1
6515; O2-NEXT:    sltiu $3, $1, 1
6516; O2-NEXT:    sync
6517; O2-NEXT:    jr $ra
6518; O2-NEXT:    nop
6519;
6520; O3-LABEL: foo:
6521; O3:       # %bb.0:
6522; O3-NEXT:    addiu $2, $zero, -4
6523; O3-NEXT:    addu $1, $5, $6
6524; O3-NEXT:    sync
6525; O3-NEXT:    and $3, $4, $2
6526; O3-NEXT:    andi $2, $4, 3
6527; O3-NEXT:    sll $4, $2, 3
6528; O3-NEXT:    ori $2, $zero, 65535
6529; O3-NEXT:    sllv $5, $2, $4
6530; O3-NEXT:    andi $2, $1, 65535
6531; O3-NEXT:    sll $1, $1, 16
6532; O3-NEXT:    sllv $8, $2, $4
6533; O3-NEXT:    andi $2, $7, 65535
6534; O3-NEXT:    nor $6, $zero, $5
6535; O3-NEXT:    sra $1, $1, 16
6536; O3-NEXT:    sllv $7, $2, $4
6537; O3-NEXT:  $BB15_1: # =>This Inner Loop Header: Depth=1
6538; O3-NEXT:    ll $9, 0($3)
6539; O3-NEXT:    and $10, $9, $5
6540; O3-NEXT:    bne $10, $8, $BB15_3
6541; O3-NEXT:    nop
6542; O3-NEXT:  # %bb.2: # in Loop: Header=BB15_1 Depth=1
6543; O3-NEXT:    and $9, $9, $6
6544; O3-NEXT:    or $9, $9, $7
6545; O3-NEXT:    sc $9, 0($3)
6546; O3-NEXT:    beqz $9, $BB15_1
6547; O3-NEXT:    nop
6548; O3-NEXT:  $BB15_3:
6549; O3-NEXT:    srlv $2, $10, $4
6550; O3-NEXT:    sll $2, $2, 16
6551; O3-NEXT:    sra $2, $2, 16
6552; O3-NEXT:  # %bb.4:
6553; O3-NEXT:    sync
6554; O3-NEXT:    xor $1, $2, $1
6555; O3-NEXT:    jr $ra
6556; O3-NEXT:    sltiu $3, $1, 1
6557;
6558; MIPS32EB-LABEL: foo:
6559; MIPS32EB:       # %bb.0:
6560; MIPS32EB-NEXT:    addu $1, $5, $6
6561; MIPS32EB-NEXT:    sync
6562; MIPS32EB-NEXT:    addiu $2, $zero, -4
6563; MIPS32EB-NEXT:    and $3, $4, $2
6564; MIPS32EB-NEXT:    andi $2, $4, 3
6565; MIPS32EB-NEXT:    xori $2, $2, 2
6566; MIPS32EB-NEXT:    sll $4, $2, 3
6567; MIPS32EB-NEXT:    ori $2, $zero, 65535
6568; MIPS32EB-NEXT:    sllv $5, $2, $4
6569; MIPS32EB-NEXT:    nor $6, $zero, $5
6570; MIPS32EB-NEXT:    andi $2, $1, 65535
6571; MIPS32EB-NEXT:    sllv $8, $2, $4
6572; MIPS32EB-NEXT:    andi $2, $7, 65535
6573; MIPS32EB-NEXT:    sllv $7, $2, $4
6574; MIPS32EB-NEXT:  $BB15_1: # =>This Inner Loop Header: Depth=1
6575; MIPS32EB-NEXT:    ll $9, 0($3)
6576; MIPS32EB-NEXT:    and $10, $9, $5
6577; MIPS32EB-NEXT:    bne $10, $8, $BB15_3
6578; MIPS32EB-NEXT:    nop
6579; MIPS32EB-NEXT:  # %bb.2: # in Loop: Header=BB15_1 Depth=1
6580; MIPS32EB-NEXT:    and $9, $9, $6
6581; MIPS32EB-NEXT:    or $9, $9, $7
6582; MIPS32EB-NEXT:    sc $9, 0($3)
6583; MIPS32EB-NEXT:    beqz $9, $BB15_1
6584; MIPS32EB-NEXT:    nop
6585; MIPS32EB-NEXT:  $BB15_3:
6586; MIPS32EB-NEXT:    srlv $2, $10, $4
6587; MIPS32EB-NEXT:    sll $2, $2, 16
6588; MIPS32EB-NEXT:    sra $2, $2, 16
6589; MIPS32EB-NEXT:  # %bb.4:
6590; MIPS32EB-NEXT:    sll $1, $1, 16
6591; MIPS32EB-NEXT:    sra $1, $1, 16
6592; MIPS32EB-NEXT:    xor $1, $2, $1
6593; MIPS32EB-NEXT:    sltiu $3, $1, 1
6594; MIPS32EB-NEXT:    sync
6595; MIPS32EB-NEXT:    jr $ra
6596; MIPS32EB-NEXT:    nop
6597  %desired = add i16 %l, %r
6598  %res = cmpxchg i16* %addr, i16 %desired, i16 %new seq_cst seq_cst
6599  ret {i16, i1} %res
6600}
6601
6602@countsint = common global i32 0, align 4
6603
6604define i32 @CheckSync(i32 signext %v) nounwind noinline {
6605; MIPS32-LABEL: CheckSync:
6606; MIPS32:       # %bb.0: # %entry
6607; MIPS32-NEXT:    lui $2, %hi(_gp_disp)
6608; MIPS32-NEXT:    addiu $2, $2, %lo(_gp_disp)
6609; MIPS32-NEXT:    addu $1, $2, $25
6610; MIPS32-NEXT:    sync
6611; MIPS32-NEXT:    lw $1, %got(countsint)($1)
6612; MIPS32-NEXT:  $BB16_1: # %entry
6613; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
6614; MIPS32-NEXT:    ll $2, 0($1)
6615; MIPS32-NEXT:    addu $3, $2, $4
6616; MIPS32-NEXT:    sc $3, 0($1)
6617; MIPS32-NEXT:    beqz $3, $BB16_1
6618; MIPS32-NEXT:    nop
6619; MIPS32-NEXT:  # %bb.2: # %entry
6620; MIPS32-NEXT:    sync
6621; MIPS32-NEXT:    jr $ra
6622; MIPS32-NEXT:    nop
6623;
6624; MIPS32O0-LABEL: CheckSync:
6625; MIPS32O0:       # %bb.0: # %entry
6626; MIPS32O0-NEXT:    lui $2, %hi(_gp_disp)
6627; MIPS32O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
6628; MIPS32O0-NEXT:    addu $1, $2, $25
6629; MIPS32O0-NEXT:    sync
6630; MIPS32O0-NEXT:    lw $3, %got(countsint)($1)
6631; MIPS32O0-NEXT:  $BB16_1: # %entry
6632; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
6633; MIPS32O0-NEXT:    ll $2, 0($3)
6634; MIPS32O0-NEXT:    addu $1, $2, $4
6635; MIPS32O0-NEXT:    sc $1, 0($3)
6636; MIPS32O0-NEXT:    beqz $1, $BB16_1
6637; MIPS32O0-NEXT:    nop
6638; MIPS32O0-NEXT:  # %bb.2: # %entry
6639; MIPS32O0-NEXT:    sync
6640; MIPS32O0-NEXT:    jr $ra
6641; MIPS32O0-NEXT:    nop
6642;
6643; MIPS32R2-LABEL: CheckSync:
6644; MIPS32R2:       # %bb.0: # %entry
6645; MIPS32R2-NEXT:    lui $2, %hi(_gp_disp)
6646; MIPS32R2-NEXT:    addiu $2, $2, %lo(_gp_disp)
6647; MIPS32R2-NEXT:    addu $1, $2, $25
6648; MIPS32R2-NEXT:    sync
6649; MIPS32R2-NEXT:    lw $1, %got(countsint)($1)
6650; MIPS32R2-NEXT:  $BB16_1: # %entry
6651; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
6652; MIPS32R2-NEXT:    ll $2, 0($1)
6653; MIPS32R2-NEXT:    addu $3, $2, $4
6654; MIPS32R2-NEXT:    sc $3, 0($1)
6655; MIPS32R2-NEXT:    beqz $3, $BB16_1
6656; MIPS32R2-NEXT:    nop
6657; MIPS32R2-NEXT:  # %bb.2: # %entry
6658; MIPS32R2-NEXT:    sync
6659; MIPS32R2-NEXT:    jr $ra
6660; MIPS32R2-NEXT:    nop
6661;
6662; MIPS32R6-LABEL: CheckSync:
6663; MIPS32R6:       # %bb.0: # %entry
6664; MIPS32R6-NEXT:    lui $2, %hi(_gp_disp)
6665; MIPS32R6-NEXT:    addiu $2, $2, %lo(_gp_disp)
6666; MIPS32R6-NEXT:    addu $1, $2, $25
6667; MIPS32R6-NEXT:    sync
6668; MIPS32R6-NEXT:    lw $1, %got(countsint)($1)
6669; MIPS32R6-NEXT:  $BB16_1: # %entry
6670; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
6671; MIPS32R6-NEXT:    ll $2, 0($1)
6672; MIPS32R6-NEXT:    addu $3, $2, $4
6673; MIPS32R6-NEXT:    sc $3, 0($1)
6674; MIPS32R6-NEXT:    beqzc $3, $BB16_1
6675; MIPS32R6-NEXT:  # %bb.2: # %entry
6676; MIPS32R6-NEXT:    sync
6677; MIPS32R6-NEXT:    jrc $ra
6678;
6679; MIPS32R6O0-LABEL: CheckSync:
6680; MIPS32R6O0:       # %bb.0: # %entry
6681; MIPS32R6O0-NEXT:    lui $2, %hi(_gp_disp)
6682; MIPS32R6O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
6683; MIPS32R6O0-NEXT:    addu $1, $2, $25
6684; MIPS32R6O0-NEXT:    sync
6685; MIPS32R6O0-NEXT:    lw $3, %got(countsint)($1)
6686; MIPS32R6O0-NEXT:  $BB16_1: # %entry
6687; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
6688; MIPS32R6O0-NEXT:    ll $2, 0($3)
6689; MIPS32R6O0-NEXT:    addu $1, $2, $4
6690; MIPS32R6O0-NEXT:    sc $1, 0($3)
6691; MIPS32R6O0-NEXT:    beqzc $1, $BB16_1
6692; MIPS32R6O0-NEXT:  # %bb.2: # %entry
6693; MIPS32R6O0-NEXT:    sync
6694; MIPS32R6O0-NEXT:    jrc $ra
6695;
6696; MIPS4-LABEL: CheckSync:
6697; MIPS4:       # %bb.0: # %entry
6698; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(CheckSync)))
6699; MIPS4-NEXT:    daddu $1, $1, $25
6700; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(CheckSync)))
6701; MIPS4-NEXT:    sync
6702; MIPS4-NEXT:    ld $1, %got_disp(countsint)($1)
6703; MIPS4-NEXT:  .LBB16_1: # %entry
6704; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
6705; MIPS4-NEXT:    ll $2, 0($1)
6706; MIPS4-NEXT:    addu $3, $2, $4
6707; MIPS4-NEXT:    sc $3, 0($1)
6708; MIPS4-NEXT:    beqz $3, .LBB16_1
6709; MIPS4-NEXT:    nop
6710; MIPS4-NEXT:  # %bb.2: # %entry
6711; MIPS4-NEXT:    sync
6712; MIPS4-NEXT:    jr $ra
6713; MIPS4-NEXT:    nop
6714;
6715; MIPS64-LABEL: CheckSync:
6716; MIPS64:       # %bb.0: # %entry
6717; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(CheckSync)))
6718; MIPS64-NEXT:    daddu $1, $1, $25
6719; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(CheckSync)))
6720; MIPS64-NEXT:    sync
6721; MIPS64-NEXT:    ld $1, %got_disp(countsint)($1)
6722; MIPS64-NEXT:  .LBB16_1: # %entry
6723; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
6724; MIPS64-NEXT:    ll $2, 0($1)
6725; MIPS64-NEXT:    addu $3, $2, $4
6726; MIPS64-NEXT:    sc $3, 0($1)
6727; MIPS64-NEXT:    beqz $3, .LBB16_1
6728; MIPS64-NEXT:    nop
6729; MIPS64-NEXT:  # %bb.2: # %entry
6730; MIPS64-NEXT:    sync
6731; MIPS64-NEXT:    jr $ra
6732; MIPS64-NEXT:    nop
6733;
6734; MIPS64R2-LABEL: CheckSync:
6735; MIPS64R2:       # %bb.0: # %entry
6736; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(CheckSync)))
6737; MIPS64R2-NEXT:    daddu $1, $1, $25
6738; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(CheckSync)))
6739; MIPS64R2-NEXT:    sync
6740; MIPS64R2-NEXT:    ld $1, %got_disp(countsint)($1)
6741; MIPS64R2-NEXT:  .LBB16_1: # %entry
6742; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
6743; MIPS64R2-NEXT:    ll $2, 0($1)
6744; MIPS64R2-NEXT:    addu $3, $2, $4
6745; MIPS64R2-NEXT:    sc $3, 0($1)
6746; MIPS64R2-NEXT:    beqz $3, .LBB16_1
6747; MIPS64R2-NEXT:    nop
6748; MIPS64R2-NEXT:  # %bb.2: # %entry
6749; MIPS64R2-NEXT:    sync
6750; MIPS64R2-NEXT:    jr $ra
6751; MIPS64R2-NEXT:    nop
6752;
6753; MIPS64R6-LABEL: CheckSync:
6754; MIPS64R6:       # %bb.0: # %entry
6755; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(CheckSync)))
6756; MIPS64R6-NEXT:    daddu $1, $1, $25
6757; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(CheckSync)))
6758; MIPS64R6-NEXT:    sync
6759; MIPS64R6-NEXT:    ld $1, %got_disp(countsint)($1)
6760; MIPS64R6-NEXT:  .LBB16_1: # %entry
6761; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
6762; MIPS64R6-NEXT:    ll $2, 0($1)
6763; MIPS64R6-NEXT:    addu $3, $2, $4
6764; MIPS64R6-NEXT:    sc $3, 0($1)
6765; MIPS64R6-NEXT:    beqzc $3, .LBB16_1
6766; MIPS64R6-NEXT:  # %bb.2: # %entry
6767; MIPS64R6-NEXT:    sync
6768; MIPS64R6-NEXT:    jrc $ra
6769;
6770; MIPS64R6O0-LABEL: CheckSync:
6771; MIPS64R6O0:       # %bb.0: # %entry
6772; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(CheckSync)))
6773; MIPS64R6O0-NEXT:    daddu $1, $1, $25
6774; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(CheckSync)))
6775; MIPS64R6O0-NEXT:    # kill: def $a0 killed $a0 killed $a0_64
6776; MIPS64R6O0-NEXT:    sync
6777; MIPS64R6O0-NEXT:    ld $3, %got_disp(countsint)($1)
6778; MIPS64R6O0-NEXT:  .LBB16_1: # %entry
6779; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
6780; MIPS64R6O0-NEXT:    ll $2, 0($3)
6781; MIPS64R6O0-NEXT:    addu $1, $2, $4
6782; MIPS64R6O0-NEXT:    sc $1, 0($3)
6783; MIPS64R6O0-NEXT:    beqzc $1, .LBB16_1
6784; MIPS64R6O0-NEXT:  # %bb.2: # %entry
6785; MIPS64R6O0-NEXT:    sync
6786; MIPS64R6O0-NEXT:    jrc $ra
6787;
6788; MM32-LABEL: CheckSync:
6789; MM32:       # %bb.0: # %entry
6790; MM32-NEXT:    lui $2, %hi(_gp_disp)
6791; MM32-NEXT:    addiu $2, $2, %lo(_gp_disp)
6792; MM32-NEXT:    addu $2, $2, $25
6793; MM32-NEXT:    sync
6794; MM32-NEXT:    lw $1, %got(countsint)($2)
6795; MM32-NEXT:  $BB16_1: # %entry
6796; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
6797; MM32-NEXT:    ll $2, 0($1)
6798; MM32-NEXT:    addu16 $3, $2, $4
6799; MM32-NEXT:    sc $3, 0($1)
6800; MM32-NEXT:    beqzc $3, $BB16_1
6801; MM32-NEXT:  # %bb.2: # %entry
6802; MM32-NEXT:    sync
6803; MM32-NEXT:    jrc $ra
6804;
6805; O1-LABEL: CheckSync:
6806; O1:       # %bb.0: # %entry
6807; O1-NEXT:    lui $2, %hi(_gp_disp)
6808; O1-NEXT:    addiu $2, $2, %lo(_gp_disp)
6809; O1-NEXT:    addu $1, $2, $25
6810; O1-NEXT:    sync
6811; O1-NEXT:    lw $1, %got(countsint)($1)
6812; O1-NEXT:  $BB16_1: # %entry
6813; O1-NEXT:    # =>This Inner Loop Header: Depth=1
6814; O1-NEXT:    ll $2, 0($1)
6815; O1-NEXT:    addu $3, $2, $4
6816; O1-NEXT:    sc $3, 0($1)
6817; O1-NEXT:    beqz $3, $BB16_1
6818; O1-NEXT:    nop
6819; O1-NEXT:  # %bb.2: # %entry
6820; O1-NEXT:    sync
6821; O1-NEXT:    jr $ra
6822; O1-NEXT:    nop
6823;
6824; O2-LABEL: CheckSync:
6825; O2:       # %bb.0: # %entry
6826; O2-NEXT:    lui $2, %hi(_gp_disp)
6827; O2-NEXT:    addiu $2, $2, %lo(_gp_disp)
6828; O2-NEXT:    addu $1, $2, $25
6829; O2-NEXT:    sync
6830; O2-NEXT:    lw $1, %got(countsint)($1)
6831; O2-NEXT:  $BB16_1: # %entry
6832; O2-NEXT:    # =>This Inner Loop Header: Depth=1
6833; O2-NEXT:    ll $2, 0($1)
6834; O2-NEXT:    addu $3, $2, $4
6835; O2-NEXT:    sc $3, 0($1)
6836; O2-NEXT:    beqz $3, $BB16_1
6837; O2-NEXT:    nop
6838; O2-NEXT:  # %bb.2: # %entry
6839; O2-NEXT:    sync
6840; O2-NEXT:    jr $ra
6841; O2-NEXT:    nop
6842;
6843; O3-LABEL: CheckSync:
6844; O3:       # %bb.0: # %entry
6845; O3-NEXT:    lui $2, %hi(_gp_disp)
6846; O3-NEXT:    addiu $2, $2, %lo(_gp_disp)
6847; O3-NEXT:    addu $1, $2, $25
6848; O3-NEXT:    sync
6849; O3-NEXT:    lw $1, %got(countsint)($1)
6850; O3-NEXT:  $BB16_1: # %entry
6851; O3-NEXT:    # =>This Inner Loop Header: Depth=1
6852; O3-NEXT:    ll $2, 0($1)
6853; O3-NEXT:    addu $3, $2, $4
6854; O3-NEXT:    sc $3, 0($1)
6855; O3-NEXT:    beqz $3, $BB16_1
6856; O3-NEXT:    nop
6857; O3-NEXT:  # %bb.2: # %entry
6858; O3-NEXT:    sync
6859; O3-NEXT:    jr $ra
6860; O3-NEXT:    nop
6861;
6862; MIPS32EB-LABEL: CheckSync:
6863; MIPS32EB:       # %bb.0: # %entry
6864; MIPS32EB-NEXT:    lui $2, %hi(_gp_disp)
6865; MIPS32EB-NEXT:    addiu $2, $2, %lo(_gp_disp)
6866; MIPS32EB-NEXT:    addu $1, $2, $25
6867; MIPS32EB-NEXT:    sync
6868; MIPS32EB-NEXT:    lw $1, %got(countsint)($1)
6869; MIPS32EB-NEXT:  $BB16_1: # %entry
6870; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
6871; MIPS32EB-NEXT:    ll $2, 0($1)
6872; MIPS32EB-NEXT:    addu $3, $2, $4
6873; MIPS32EB-NEXT:    sc $3, 0($1)
6874; MIPS32EB-NEXT:    beqz $3, $BB16_1
6875; MIPS32EB-NEXT:    nop
6876; MIPS32EB-NEXT:  # %bb.2: # %entry
6877; MIPS32EB-NEXT:    sync
6878; MIPS32EB-NEXT:    jr $ra
6879; MIPS32EB-NEXT:    nop
6880entry:
6881  %0 = atomicrmw add i32* @countsint, i32 %v seq_cst
6882  ret i32 %0
6883}
6884
6885; make sure that this assertion in
6886; TwoAddressInstructionPass::TryInstructionTransform does not fail:
6887;
6888; line 1203: assert(TargetRegisterInfo::isVirtualRegister(regB) &&
6889;
6890; it failed when MipsDAGToDAGISel::ReplaceUsesWithZeroReg replaced an
6891; operand of an atomic instruction with register $zero.
6892@a = external global i32
6893
6894define i32 @zeroreg() nounwind {
6895; MIPS32-LABEL: zeroreg:
6896; MIPS32:       # %bb.0: # %entry
6897; MIPS32-NEXT:    lui $2, %hi(_gp_disp)
6898; MIPS32-NEXT:    addiu $2, $2, %lo(_gp_disp)
6899; MIPS32-NEXT:    addu $1, $2, $25
6900; MIPS32-NEXT:    sync
6901; MIPS32-NEXT:    addiu $2, $zero, 0
6902; MIPS32-NEXT:    addiu $3, $zero, 1
6903; MIPS32-NEXT:    lw $1, %got(a)($1)
6904; MIPS32-NEXT:  $BB17_1: # %entry
6905; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
6906; MIPS32-NEXT:    ll $4, 0($1)
6907; MIPS32-NEXT:    bne $4, $3, $BB17_3
6908; MIPS32-NEXT:    nop
6909; MIPS32-NEXT:  # %bb.2: # %entry
6910; MIPS32-NEXT:    # in Loop: Header=BB17_1 Depth=1
6911; MIPS32-NEXT:    move $5, $2
6912; MIPS32-NEXT:    sc $5, 0($1)
6913; MIPS32-NEXT:    beqz $5, $BB17_1
6914; MIPS32-NEXT:    nop
6915; MIPS32-NEXT:  $BB17_3: # %entry
6916; MIPS32-NEXT:    xor $1, $4, $3
6917; MIPS32-NEXT:    sltiu $2, $1, 1
6918; MIPS32-NEXT:    sync
6919; MIPS32-NEXT:    jr $ra
6920; MIPS32-NEXT:    nop
6921;
6922; MIPS32O0-LABEL: zeroreg:
6923; MIPS32O0:       # %bb.0: # %entry
6924; MIPS32O0-NEXT:    lui $2, %hi(_gp_disp)
6925; MIPS32O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
6926; MIPS32O0-NEXT:    addu $1, $2, $25
6927; MIPS32O0-NEXT:    sync
6928; MIPS32O0-NEXT:    lw $4, %got(a)($1)
6929; MIPS32O0-NEXT:    addiu $6, $zero, 0
6930; MIPS32O0-NEXT:    addiu $2, $zero, 1
6931; MIPS32O0-NEXT:    move $5, $2
6932; MIPS32O0-NEXT:  $BB17_1: # %entry
6933; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
6934; MIPS32O0-NEXT:    ll $1, 0($4)
6935; MIPS32O0-NEXT:    bne $1, $5, $BB17_3
6936; MIPS32O0-NEXT:    nop
6937; MIPS32O0-NEXT:  # %bb.2: # %entry
6938; MIPS32O0-NEXT:    # in Loop: Header=BB17_1 Depth=1
6939; MIPS32O0-NEXT:    move $3, $6
6940; MIPS32O0-NEXT:    sc $3, 0($4)
6941; MIPS32O0-NEXT:    beqz $3, $BB17_1
6942; MIPS32O0-NEXT:    nop
6943; MIPS32O0-NEXT:  $BB17_3: # %entry
6944; MIPS32O0-NEXT:    xor $2, $1, $2
6945; MIPS32O0-NEXT:    sltiu $2, $2, 1
6946; MIPS32O0-NEXT:    sync
6947; MIPS32O0-NEXT:    addiu $2, $zero, 1
6948; MIPS32O0-NEXT:    xor $1, $1, $2
6949; MIPS32O0-NEXT:    sltiu $1, $1, 1
6950; MIPS32O0-NEXT:    andi $2, $1, 1
6951; MIPS32O0-NEXT:    jr $ra
6952; MIPS32O0-NEXT:    nop
6953;
6954; MIPS32R2-LABEL: zeroreg:
6955; MIPS32R2:       # %bb.0: # %entry
6956; MIPS32R2-NEXT:    lui $2, %hi(_gp_disp)
6957; MIPS32R2-NEXT:    addiu $2, $2, %lo(_gp_disp)
6958; MIPS32R2-NEXT:    addu $1, $2, $25
6959; MIPS32R2-NEXT:    sync
6960; MIPS32R2-NEXT:    addiu $2, $zero, 0
6961; MIPS32R2-NEXT:    addiu $3, $zero, 1
6962; MIPS32R2-NEXT:    lw $1, %got(a)($1)
6963; MIPS32R2-NEXT:  $BB17_1: # %entry
6964; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
6965; MIPS32R2-NEXT:    ll $4, 0($1)
6966; MIPS32R2-NEXT:    bne $4, $3, $BB17_3
6967; MIPS32R2-NEXT:    nop
6968; MIPS32R2-NEXT:  # %bb.2: # %entry
6969; MIPS32R2-NEXT:    # in Loop: Header=BB17_1 Depth=1
6970; MIPS32R2-NEXT:    move $5, $2
6971; MIPS32R2-NEXT:    sc $5, 0($1)
6972; MIPS32R2-NEXT:    beqz $5, $BB17_1
6973; MIPS32R2-NEXT:    nop
6974; MIPS32R2-NEXT:  $BB17_3: # %entry
6975; MIPS32R2-NEXT:    xor $1, $4, $3
6976; MIPS32R2-NEXT:    sltiu $2, $1, 1
6977; MIPS32R2-NEXT:    sync
6978; MIPS32R2-NEXT:    jr $ra
6979; MIPS32R2-NEXT:    nop
6980;
6981; MIPS32R6-LABEL: zeroreg:
6982; MIPS32R6:       # %bb.0: # %entry
6983; MIPS32R6-NEXT:    lui $2, %hi(_gp_disp)
6984; MIPS32R6-NEXT:    addiu $2, $2, %lo(_gp_disp)
6985; MIPS32R6-NEXT:    addu $1, $2, $25
6986; MIPS32R6-NEXT:    sync
6987; MIPS32R6-NEXT:    addiu $2, $zero, 0
6988; MIPS32R6-NEXT:    addiu $3, $zero, 1
6989; MIPS32R6-NEXT:    lw $1, %got(a)($1)
6990; MIPS32R6-NEXT:  $BB17_1: # %entry
6991; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
6992; MIPS32R6-NEXT:    ll $4, 0($1)
6993; MIPS32R6-NEXT:    bnec $4, $3, $BB17_3
6994; MIPS32R6-NEXT:  # %bb.2: # %entry
6995; MIPS32R6-NEXT:    # in Loop: Header=BB17_1 Depth=1
6996; MIPS32R6-NEXT:    move $5, $2
6997; MIPS32R6-NEXT:    sc $5, 0($1)
6998; MIPS32R6-NEXT:    beqzc $5, $BB17_1
6999; MIPS32R6-NEXT:  $BB17_3: # %entry
7000; MIPS32R6-NEXT:    xor $1, $4, $3
7001; MIPS32R6-NEXT:    sltiu $2, $1, 1
7002; MIPS32R6-NEXT:    sync
7003; MIPS32R6-NEXT:    jrc $ra
7004;
7005; MIPS32R6O0-LABEL: zeroreg:
7006; MIPS32R6O0:       # %bb.0: # %entry
7007; MIPS32R6O0-NEXT:    lui $2, %hi(_gp_disp)
7008; MIPS32R6O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
7009; MIPS32R6O0-NEXT:    addu $1, $2, $25
7010; MIPS32R6O0-NEXT:    sync
7011; MIPS32R6O0-NEXT:    lw $4, %got(a)($1)
7012; MIPS32R6O0-NEXT:    addiu $6, $zero, 0
7013; MIPS32R6O0-NEXT:    addiu $2, $zero, 1
7014; MIPS32R6O0-NEXT:    move $5, $2
7015; MIPS32R6O0-NEXT:  $BB17_1: # %entry
7016; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
7017; MIPS32R6O0-NEXT:    ll $1, 0($4)
7018; MIPS32R6O0-NEXT:    bnec $1, $5, $BB17_3
7019; MIPS32R6O0-NEXT:  # %bb.2: # %entry
7020; MIPS32R6O0-NEXT:    # in Loop: Header=BB17_1 Depth=1
7021; MIPS32R6O0-NEXT:    move $3, $6
7022; MIPS32R6O0-NEXT:    sc $3, 0($4)
7023; MIPS32R6O0-NEXT:    beqzc $3, $BB17_1
7024; MIPS32R6O0-NEXT:  $BB17_3: # %entry
7025; MIPS32R6O0-NEXT:    xor $1, $1, $2
7026; MIPS32R6O0-NEXT:    sltiu $2, $1, 1
7027; MIPS32R6O0-NEXT:    sync
7028; MIPS32R6O0-NEXT:    jrc $ra
7029;
7030; MIPS4-LABEL: zeroreg:
7031; MIPS4:       # %bb.0: # %entry
7032; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(zeroreg)))
7033; MIPS4-NEXT:    daddu $1, $1, $25
7034; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(zeroreg)))
7035; MIPS4-NEXT:    sync
7036; MIPS4-NEXT:    addiu $2, $zero, 0
7037; MIPS4-NEXT:    addiu $3, $zero, 1
7038; MIPS4-NEXT:    ld $1, %got_disp(a)($1)
7039; MIPS4-NEXT:  .LBB17_1: # %entry
7040; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
7041; MIPS4-NEXT:    ll $4, 0($1)
7042; MIPS4-NEXT:    bne $4, $3, .LBB17_3
7043; MIPS4-NEXT:    nop
7044; MIPS4-NEXT:  # %bb.2: # %entry
7045; MIPS4-NEXT:    # in Loop: Header=BB17_1 Depth=1
7046; MIPS4-NEXT:    move $5, $2
7047; MIPS4-NEXT:    sc $5, 0($1)
7048; MIPS4-NEXT:    beqz $5, .LBB17_1
7049; MIPS4-NEXT:    nop
7050; MIPS4-NEXT:  .LBB17_3: # %entry
7051; MIPS4-NEXT:    xor $1, $4, $3
7052; MIPS4-NEXT:    sltiu $2, $1, 1
7053; MIPS4-NEXT:    sync
7054; MIPS4-NEXT:    jr $ra
7055; MIPS4-NEXT:    nop
7056;
7057; MIPS64-LABEL: zeroreg:
7058; MIPS64:       # %bb.0: # %entry
7059; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(zeroreg)))
7060; MIPS64-NEXT:    daddu $1, $1, $25
7061; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(zeroreg)))
7062; MIPS64-NEXT:    sync
7063; MIPS64-NEXT:    addiu $2, $zero, 0
7064; MIPS64-NEXT:    addiu $3, $zero, 1
7065; MIPS64-NEXT:    ld $1, %got_disp(a)($1)
7066; MIPS64-NEXT:  .LBB17_1: # %entry
7067; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
7068; MIPS64-NEXT:    ll $4, 0($1)
7069; MIPS64-NEXT:    bne $4, $3, .LBB17_3
7070; MIPS64-NEXT:    nop
7071; MIPS64-NEXT:  # %bb.2: # %entry
7072; MIPS64-NEXT:    # in Loop: Header=BB17_1 Depth=1
7073; MIPS64-NEXT:    move $5, $2
7074; MIPS64-NEXT:    sc $5, 0($1)
7075; MIPS64-NEXT:    beqz $5, .LBB17_1
7076; MIPS64-NEXT:    nop
7077; MIPS64-NEXT:  .LBB17_3: # %entry
7078; MIPS64-NEXT:    xor $1, $4, $3
7079; MIPS64-NEXT:    sltiu $2, $1, 1
7080; MIPS64-NEXT:    sync
7081; MIPS64-NEXT:    jr $ra
7082; MIPS64-NEXT:    nop
7083;
7084; MIPS64R2-LABEL: zeroreg:
7085; MIPS64R2:       # %bb.0: # %entry
7086; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(zeroreg)))
7087; MIPS64R2-NEXT:    daddu $1, $1, $25
7088; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(zeroreg)))
7089; MIPS64R2-NEXT:    sync
7090; MIPS64R2-NEXT:    addiu $2, $zero, 0
7091; MIPS64R2-NEXT:    addiu $3, $zero, 1
7092; MIPS64R2-NEXT:    ld $1, %got_disp(a)($1)
7093; MIPS64R2-NEXT:  .LBB17_1: # %entry
7094; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
7095; MIPS64R2-NEXT:    ll $4, 0($1)
7096; MIPS64R2-NEXT:    bne $4, $3, .LBB17_3
7097; MIPS64R2-NEXT:    nop
7098; MIPS64R2-NEXT:  # %bb.2: # %entry
7099; MIPS64R2-NEXT:    # in Loop: Header=BB17_1 Depth=1
7100; MIPS64R2-NEXT:    move $5, $2
7101; MIPS64R2-NEXT:    sc $5, 0($1)
7102; MIPS64R2-NEXT:    beqz $5, .LBB17_1
7103; MIPS64R2-NEXT:    nop
7104; MIPS64R2-NEXT:  .LBB17_3: # %entry
7105; MIPS64R2-NEXT:    xor $1, $4, $3
7106; MIPS64R2-NEXT:    sltiu $2, $1, 1
7107; MIPS64R2-NEXT:    sync
7108; MIPS64R2-NEXT:    jr $ra
7109; MIPS64R2-NEXT:    nop
7110;
7111; MIPS64R6-LABEL: zeroreg:
7112; MIPS64R6:       # %bb.0: # %entry
7113; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(zeroreg)))
7114; MIPS64R6-NEXT:    daddu $1, $1, $25
7115; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(zeroreg)))
7116; MIPS64R6-NEXT:    sync
7117; MIPS64R6-NEXT:    addiu $2, $zero, 0
7118; MIPS64R6-NEXT:    addiu $3, $zero, 1
7119; MIPS64R6-NEXT:    ld $1, %got_disp(a)($1)
7120; MIPS64R6-NEXT:  .LBB17_1: # %entry
7121; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
7122; MIPS64R6-NEXT:    ll $4, 0($1)
7123; MIPS64R6-NEXT:    bnec $4, $3, .LBB17_3
7124; MIPS64R6-NEXT:  # %bb.2: # %entry
7125; MIPS64R6-NEXT:    # in Loop: Header=BB17_1 Depth=1
7126; MIPS64R6-NEXT:    move $5, $2
7127; MIPS64R6-NEXT:    sc $5, 0($1)
7128; MIPS64R6-NEXT:    beqzc $5, .LBB17_1
7129; MIPS64R6-NEXT:  .LBB17_3: # %entry
7130; MIPS64R6-NEXT:    xor $1, $4, $3
7131; MIPS64R6-NEXT:    sltiu $2, $1, 1
7132; MIPS64R6-NEXT:    sync
7133; MIPS64R6-NEXT:    jrc $ra
7134;
7135; MIPS64R6O0-LABEL: zeroreg:
7136; MIPS64R6O0:       # %bb.0: # %entry
7137; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(zeroreg)))
7138; MIPS64R6O0-NEXT:    daddu $1, $1, $25
7139; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(zeroreg)))
7140; MIPS64R6O0-NEXT:    sync
7141; MIPS64R6O0-NEXT:    ld $4, %got_disp(a)($1)
7142; MIPS64R6O0-NEXT:    addiu $6, $zero, 0
7143; MIPS64R6O0-NEXT:    addiu $2, $zero, 1
7144; MIPS64R6O0-NEXT:    move $5, $2
7145; MIPS64R6O0-NEXT:  .LBB17_1: # %entry
7146; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
7147; MIPS64R6O0-NEXT:    ll $1, 0($4)
7148; MIPS64R6O0-NEXT:    bnec $1, $5, .LBB17_3
7149; MIPS64R6O0-NEXT:  # %bb.2: # %entry
7150; MIPS64R6O0-NEXT:    # in Loop: Header=BB17_1 Depth=1
7151; MIPS64R6O0-NEXT:    move $3, $6
7152; MIPS64R6O0-NEXT:    sc $3, 0($4)
7153; MIPS64R6O0-NEXT:    beqzc $3, .LBB17_1
7154; MIPS64R6O0-NEXT:  .LBB17_3: # %entry
7155; MIPS64R6O0-NEXT:    xor $1, $1, $2
7156; MIPS64R6O0-NEXT:    sltiu $2, $1, 1
7157; MIPS64R6O0-NEXT:    sync
7158; MIPS64R6O0-NEXT:    jrc $ra
7159;
7160; MM32-LABEL: zeroreg:
7161; MM32:       # %bb.0: # %entry
7162; MM32-NEXT:    lui $2, %hi(_gp_disp)
7163; MM32-NEXT:    addiu $2, $2, %lo(_gp_disp)
7164; MM32-NEXT:    addu $2, $2, $25
7165; MM32-NEXT:    sync
7166; MM32-NEXT:    li16 $3, 0
7167; MM32-NEXT:    li16 $4, 1
7168; MM32-NEXT:    lw $1, %got(a)($2)
7169; MM32-NEXT:  $BB17_1: # %entry
7170; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
7171; MM32-NEXT:    ll $2, 0($1)
7172; MM32-NEXT:    bne $2, $4, $BB17_3
7173; MM32-NEXT:    nop
7174; MM32-NEXT:  # %bb.2: # %entry
7175; MM32-NEXT:    # in Loop: Header=BB17_1 Depth=1
7176; MM32-NEXT:    move $5, $3
7177; MM32-NEXT:    sc $5, 0($1)
7178; MM32-NEXT:    beqzc $5, $BB17_1
7179; MM32-NEXT:  $BB17_3: # %entry
7180; MM32-NEXT:    xor $1, $2, $4
7181; MM32-NEXT:    sltiu $2, $1, 1
7182; MM32-NEXT:    sync
7183; MM32-NEXT:    jrc $ra
7184;
7185; O1-LABEL: zeroreg:
7186; O1:       # %bb.0: # %entry
7187; O1-NEXT:    lui $2, %hi(_gp_disp)
7188; O1-NEXT:    addiu $2, $2, %lo(_gp_disp)
7189; O1-NEXT:    addu $1, $2, $25
7190; O1-NEXT:    sync
7191; O1-NEXT:    addiu $2, $zero, 0
7192; O1-NEXT:    addiu $3, $zero, 1
7193; O1-NEXT:    lw $1, %got(a)($1)
7194; O1-NEXT:  $BB17_1: # %entry
7195; O1-NEXT:    # =>This Inner Loop Header: Depth=1
7196; O1-NEXT:    ll $4, 0($1)
7197; O1-NEXT:    bne $4, $3, $BB17_3
7198; O1-NEXT:    nop
7199; O1-NEXT:  # %bb.2: # %entry
7200; O1-NEXT:    # in Loop: Header=BB17_1 Depth=1
7201; O1-NEXT:    move $5, $2
7202; O1-NEXT:    sc $5, 0($1)
7203; O1-NEXT:    beqz $5, $BB17_1
7204; O1-NEXT:    nop
7205; O1-NEXT:  $BB17_3: # %entry
7206; O1-NEXT:    xor $1, $4, $3
7207; O1-NEXT:    sltiu $2, $1, 1
7208; O1-NEXT:    sync
7209; O1-NEXT:    jr $ra
7210; O1-NEXT:    nop
7211;
7212; O2-LABEL: zeroreg:
7213; O2:       # %bb.0: # %entry
7214; O2-NEXT:    lui $2, %hi(_gp_disp)
7215; O2-NEXT:    addiu $2, $2, %lo(_gp_disp)
7216; O2-NEXT:    addu $1, $2, $25
7217; O2-NEXT:    sync
7218; O2-NEXT:    addiu $2, $zero, 0
7219; O2-NEXT:    addiu $3, $zero, 1
7220; O2-NEXT:    lw $1, %got(a)($1)
7221; O2-NEXT:  $BB17_1: # %entry
7222; O2-NEXT:    # =>This Inner Loop Header: Depth=1
7223; O2-NEXT:    ll $4, 0($1)
7224; O2-NEXT:    bne $4, $3, $BB17_3
7225; O2-NEXT:    nop
7226; O2-NEXT:  # %bb.2: # %entry
7227; O2-NEXT:    # in Loop: Header=BB17_1 Depth=1
7228; O2-NEXT:    move $5, $2
7229; O2-NEXT:    sc $5, 0($1)
7230; O2-NEXT:    beqz $5, $BB17_1
7231; O2-NEXT:    nop
7232; O2-NEXT:  $BB17_3: # %entry
7233; O2-NEXT:    xor $1, $4, $3
7234; O2-NEXT:    sltiu $2, $1, 1
7235; O2-NEXT:    sync
7236; O2-NEXT:    jr $ra
7237; O2-NEXT:    nop
7238;
7239; O3-LABEL: zeroreg:
7240; O3:       # %bb.0: # %entry
7241; O3-NEXT:    lui $2, %hi(_gp_disp)
7242; O3-NEXT:    addiu $2, $2, %lo(_gp_disp)
7243; O3-NEXT:    addu $1, $2, $25
7244; O3-NEXT:    addiu $2, $zero, 0
7245; O3-NEXT:    addiu $3, $zero, 1
7246; O3-NEXT:    sync
7247; O3-NEXT:    lw $1, %got(a)($1)
7248; O3-NEXT:  $BB17_1: # %entry
7249; O3-NEXT:    # =>This Inner Loop Header: Depth=1
7250; O3-NEXT:    ll $4, 0($1)
7251; O3-NEXT:    bne $4, $3, $BB17_3
7252; O3-NEXT:    nop
7253; O3-NEXT:  # %bb.2: # %entry
7254; O3-NEXT:    # in Loop: Header=BB17_1 Depth=1
7255; O3-NEXT:    move $5, $2
7256; O3-NEXT:    sc $5, 0($1)
7257; O3-NEXT:    beqz $5, $BB17_1
7258; O3-NEXT:    nop
7259; O3-NEXT:  $BB17_3: # %entry
7260; O3-NEXT:    sync
7261; O3-NEXT:    xor $1, $4, $3
7262; O3-NEXT:    jr $ra
7263; O3-NEXT:    sltiu $2, $1, 1
7264;
7265; MIPS32EB-LABEL: zeroreg:
7266; MIPS32EB:       # %bb.0: # %entry
7267; MIPS32EB-NEXT:    lui $2, %hi(_gp_disp)
7268; MIPS32EB-NEXT:    addiu $2, $2, %lo(_gp_disp)
7269; MIPS32EB-NEXT:    addu $1, $2, $25
7270; MIPS32EB-NEXT:    sync
7271; MIPS32EB-NEXT:    addiu $2, $zero, 0
7272; MIPS32EB-NEXT:    addiu $3, $zero, 1
7273; MIPS32EB-NEXT:    lw $1, %got(a)($1)
7274; MIPS32EB-NEXT:  $BB17_1: # %entry
7275; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
7276; MIPS32EB-NEXT:    ll $4, 0($1)
7277; MIPS32EB-NEXT:    bne $4, $3, $BB17_3
7278; MIPS32EB-NEXT:    nop
7279; MIPS32EB-NEXT:  # %bb.2: # %entry
7280; MIPS32EB-NEXT:    # in Loop: Header=BB17_1 Depth=1
7281; MIPS32EB-NEXT:    move $5, $2
7282; MIPS32EB-NEXT:    sc $5, 0($1)
7283; MIPS32EB-NEXT:    beqz $5, $BB17_1
7284; MIPS32EB-NEXT:    nop
7285; MIPS32EB-NEXT:  $BB17_3: # %entry
7286; MIPS32EB-NEXT:    xor $1, $4, $3
7287; MIPS32EB-NEXT:    sltiu $2, $1, 1
7288; MIPS32EB-NEXT:    sync
7289; MIPS32EB-NEXT:    jr $ra
7290; MIPS32EB-NEXT:    nop
7291entry:
7292  %pair0 = cmpxchg i32* @a, i32 1, i32 0 seq_cst seq_cst
7293  %0 = extractvalue { i32, i1 } %pair0, 0
7294  %1 = icmp eq i32 %0, 1
7295  %conv = zext i1 %1 to i32
7296  ret i32 %conv
7297}
7298
7299; Check that MIPS32R6 has the correct offset range.
7300; FIXME: At the moment, we don't seem to do addr+offset for any atomic load/store.
7301define i32 @AtomicLoadAdd32_OffGt9Bit(i32 signext %incr) nounwind {
7302; MIPS32-LABEL: AtomicLoadAdd32_OffGt9Bit:
7303; MIPS32:       # %bb.0: # %entry
7304; MIPS32-NEXT:    lui $2, %hi(_gp_disp)
7305; MIPS32-NEXT:    addiu $2, $2, %lo(_gp_disp)
7306; MIPS32-NEXT:    addu $1, $2, $25
7307; MIPS32-NEXT:    lw $1, %got(x)($1)
7308; MIPS32-NEXT:    addiu $1, $1, 1024
7309; MIPS32-NEXT:  $BB18_1: # %entry
7310; MIPS32-NEXT:    # =>This Inner Loop Header: Depth=1
7311; MIPS32-NEXT:    ll $2, 0($1)
7312; MIPS32-NEXT:    addu $3, $2, $4
7313; MIPS32-NEXT:    sc $3, 0($1)
7314; MIPS32-NEXT:    beqz $3, $BB18_1
7315; MIPS32-NEXT:    nop
7316; MIPS32-NEXT:  # %bb.2: # %entry
7317; MIPS32-NEXT:    jr $ra
7318; MIPS32-NEXT:    nop
7319;
7320; MIPS32O0-LABEL: AtomicLoadAdd32_OffGt9Bit:
7321; MIPS32O0:       # %bb.0: # %entry
7322; MIPS32O0-NEXT:    lui $2, %hi(_gp_disp)
7323; MIPS32O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
7324; MIPS32O0-NEXT:    addu $1, $2, $25
7325; MIPS32O0-NEXT:    lw $1, %got(x)($1)
7326; MIPS32O0-NEXT:    addiu $3, $1, 1024
7327; MIPS32O0-NEXT:  $BB18_1: # %entry
7328; MIPS32O0-NEXT:    # =>This Inner Loop Header: Depth=1
7329; MIPS32O0-NEXT:    ll $2, 0($3)
7330; MIPS32O0-NEXT:    addu $1, $2, $4
7331; MIPS32O0-NEXT:    sc $1, 0($3)
7332; MIPS32O0-NEXT:    beqz $1, $BB18_1
7333; MIPS32O0-NEXT:    nop
7334; MIPS32O0-NEXT:  # %bb.2: # %entry
7335; MIPS32O0-NEXT:    jr $ra
7336; MIPS32O0-NEXT:    nop
7337;
7338; MIPS32R2-LABEL: AtomicLoadAdd32_OffGt9Bit:
7339; MIPS32R2:       # %bb.0: # %entry
7340; MIPS32R2-NEXT:    lui $2, %hi(_gp_disp)
7341; MIPS32R2-NEXT:    addiu $2, $2, %lo(_gp_disp)
7342; MIPS32R2-NEXT:    addu $1, $2, $25
7343; MIPS32R2-NEXT:    lw $1, %got(x)($1)
7344; MIPS32R2-NEXT:    addiu $1, $1, 1024
7345; MIPS32R2-NEXT:  $BB18_1: # %entry
7346; MIPS32R2-NEXT:    # =>This Inner Loop Header: Depth=1
7347; MIPS32R2-NEXT:    ll $2, 0($1)
7348; MIPS32R2-NEXT:    addu $3, $2, $4
7349; MIPS32R2-NEXT:    sc $3, 0($1)
7350; MIPS32R2-NEXT:    beqz $3, $BB18_1
7351; MIPS32R2-NEXT:    nop
7352; MIPS32R2-NEXT:  # %bb.2: # %entry
7353; MIPS32R2-NEXT:    jr $ra
7354; MIPS32R2-NEXT:    nop
7355;
7356; MIPS32R6-LABEL: AtomicLoadAdd32_OffGt9Bit:
7357; MIPS32R6:       # %bb.0: # %entry
7358; MIPS32R6-NEXT:    lui $2, %hi(_gp_disp)
7359; MIPS32R6-NEXT:    addiu $2, $2, %lo(_gp_disp)
7360; MIPS32R6-NEXT:    addu $1, $2, $25
7361; MIPS32R6-NEXT:    lw $1, %got(x)($1)
7362; MIPS32R6-NEXT:    addiu $1, $1, 1024
7363; MIPS32R6-NEXT:  $BB18_1: # %entry
7364; MIPS32R6-NEXT:    # =>This Inner Loop Header: Depth=1
7365; MIPS32R6-NEXT:    ll $2, 0($1)
7366; MIPS32R6-NEXT:    addu $3, $2, $4
7367; MIPS32R6-NEXT:    sc $3, 0($1)
7368; MIPS32R6-NEXT:    beqzc $3, $BB18_1
7369; MIPS32R6-NEXT:    nop
7370; MIPS32R6-NEXT:  # %bb.2: # %entry
7371; MIPS32R6-NEXT:    jrc $ra
7372;
7373; MIPS32R6O0-LABEL: AtomicLoadAdd32_OffGt9Bit:
7374; MIPS32R6O0:       # %bb.0: # %entry
7375; MIPS32R6O0-NEXT:    lui $2, %hi(_gp_disp)
7376; MIPS32R6O0-NEXT:    addiu $2, $2, %lo(_gp_disp)
7377; MIPS32R6O0-NEXT:    addu $1, $2, $25
7378; MIPS32R6O0-NEXT:    lw $1, %got(x)($1)
7379; MIPS32R6O0-NEXT:    addiu $3, $1, 1024
7380; MIPS32R6O0-NEXT:  $BB18_1: # %entry
7381; MIPS32R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
7382; MIPS32R6O0-NEXT:    ll $2, 0($3)
7383; MIPS32R6O0-NEXT:    addu $1, $2, $4
7384; MIPS32R6O0-NEXT:    sc $1, 0($3)
7385; MIPS32R6O0-NEXT:    beqzc $1, $BB18_1
7386; MIPS32R6O0-NEXT:    nop
7387; MIPS32R6O0-NEXT:  # %bb.2: # %entry
7388; MIPS32R6O0-NEXT:    jrc $ra
7389;
7390; MIPS4-LABEL: AtomicLoadAdd32_OffGt9Bit:
7391; MIPS4:       # %bb.0: # %entry
7392; MIPS4-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd32_OffGt9Bit)))
7393; MIPS4-NEXT:    daddu $1, $1, $25
7394; MIPS4-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd32_OffGt9Bit)))
7395; MIPS4-NEXT:    ld $1, %got_disp(x)($1)
7396; MIPS4-NEXT:    daddiu $1, $1, 1024
7397; MIPS4-NEXT:  .LBB18_1: # %entry
7398; MIPS4-NEXT:    # =>This Inner Loop Header: Depth=1
7399; MIPS4-NEXT:    ll $2, 0($1)
7400; MIPS4-NEXT:    addu $3, $2, $4
7401; MIPS4-NEXT:    sc $3, 0($1)
7402; MIPS4-NEXT:    beqz $3, .LBB18_1
7403; MIPS4-NEXT:    nop
7404; MIPS4-NEXT:  # %bb.2: # %entry
7405; MIPS4-NEXT:    jr $ra
7406; MIPS4-NEXT:    nop
7407;
7408; MIPS64-LABEL: AtomicLoadAdd32_OffGt9Bit:
7409; MIPS64:       # %bb.0: # %entry
7410; MIPS64-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd32_OffGt9Bit)))
7411; MIPS64-NEXT:    daddu $1, $1, $25
7412; MIPS64-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd32_OffGt9Bit)))
7413; MIPS64-NEXT:    ld $1, %got_disp(x)($1)
7414; MIPS64-NEXT:    daddiu $1, $1, 1024
7415; MIPS64-NEXT:  .LBB18_1: # %entry
7416; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
7417; MIPS64-NEXT:    ll $2, 0($1)
7418; MIPS64-NEXT:    addu $3, $2, $4
7419; MIPS64-NEXT:    sc $3, 0($1)
7420; MIPS64-NEXT:    beqz $3, .LBB18_1
7421; MIPS64-NEXT:    nop
7422; MIPS64-NEXT:  # %bb.2: # %entry
7423; MIPS64-NEXT:    jr $ra
7424; MIPS64-NEXT:    nop
7425;
7426; MIPS64R2-LABEL: AtomicLoadAdd32_OffGt9Bit:
7427; MIPS64R2:       # %bb.0: # %entry
7428; MIPS64R2-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd32_OffGt9Bit)))
7429; MIPS64R2-NEXT:    daddu $1, $1, $25
7430; MIPS64R2-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd32_OffGt9Bit)))
7431; MIPS64R2-NEXT:    ld $1, %got_disp(x)($1)
7432; MIPS64R2-NEXT:    daddiu $1, $1, 1024
7433; MIPS64R2-NEXT:  .LBB18_1: # %entry
7434; MIPS64R2-NEXT:    # =>This Inner Loop Header: Depth=1
7435; MIPS64R2-NEXT:    ll $2, 0($1)
7436; MIPS64R2-NEXT:    addu $3, $2, $4
7437; MIPS64R2-NEXT:    sc $3, 0($1)
7438; MIPS64R2-NEXT:    beqz $3, .LBB18_1
7439; MIPS64R2-NEXT:    nop
7440; MIPS64R2-NEXT:  # %bb.2: # %entry
7441; MIPS64R2-NEXT:    jr $ra
7442; MIPS64R2-NEXT:    nop
7443;
7444; MIPS64R6-LABEL: AtomicLoadAdd32_OffGt9Bit:
7445; MIPS64R6:       # %bb.0: # %entry
7446; MIPS64R6-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd32_OffGt9Bit)))
7447; MIPS64R6-NEXT:    daddu $1, $1, $25
7448; MIPS64R6-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd32_OffGt9Bit)))
7449; MIPS64R6-NEXT:    ld $1, %got_disp(x)($1)
7450; MIPS64R6-NEXT:    daddiu $1, $1, 1024
7451; MIPS64R6-NEXT:  .LBB18_1: # %entry
7452; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
7453; MIPS64R6-NEXT:    ll $2, 0($1)
7454; MIPS64R6-NEXT:    addu $3, $2, $4
7455; MIPS64R6-NEXT:    sc $3, 0($1)
7456; MIPS64R6-NEXT:    beqzc $3, .LBB18_1
7457; MIPS64R6-NEXT:    nop
7458; MIPS64R6-NEXT:  # %bb.2: # %entry
7459; MIPS64R6-NEXT:    jrc $ra
7460;
7461; MIPS64R6O0-LABEL: AtomicLoadAdd32_OffGt9Bit:
7462; MIPS64R6O0:       # %bb.0: # %entry
7463; MIPS64R6O0-NEXT:    lui $1, %hi(%neg(%gp_rel(AtomicLoadAdd32_OffGt9Bit)))
7464; MIPS64R6O0-NEXT:    daddu $1, $1, $25
7465; MIPS64R6O0-NEXT:    daddiu $1, $1, %lo(%neg(%gp_rel(AtomicLoadAdd32_OffGt9Bit)))
7466; MIPS64R6O0-NEXT:    # kill: def $a0 killed $a0 killed $a0_64
7467; MIPS64R6O0-NEXT:    ld $1, %got_disp(x)($1)
7468; MIPS64R6O0-NEXT:    daddiu $3, $1, 1024
7469; MIPS64R6O0-NEXT:  .LBB18_1: # %entry
7470; MIPS64R6O0-NEXT:    # =>This Inner Loop Header: Depth=1
7471; MIPS64R6O0-NEXT:    ll $2, 0($3)
7472; MIPS64R6O0-NEXT:    addu $1, $2, $4
7473; MIPS64R6O0-NEXT:    sc $1, 0($3)
7474; MIPS64R6O0-NEXT:    beqzc $1, .LBB18_1
7475; MIPS64R6O0-NEXT:    nop
7476; MIPS64R6O0-NEXT:  # %bb.2: # %entry
7477; MIPS64R6O0-NEXT:    jrc $ra
7478;
7479; MM32-LABEL: AtomicLoadAdd32_OffGt9Bit:
7480; MM32:       # %bb.0: # %entry
7481; MM32-NEXT:    lui $2, %hi(_gp_disp)
7482; MM32-NEXT:    addiu $2, $2, %lo(_gp_disp)
7483; MM32-NEXT:    addu $2, $2, $25
7484; MM32-NEXT:    lw $1, %got(x)($2)
7485; MM32-NEXT:    addiu $1, $1, 1024
7486; MM32-NEXT:  $BB18_1: # %entry
7487; MM32-NEXT:    # =>This Inner Loop Header: Depth=1
7488; MM32-NEXT:    ll $2, 0($1)
7489; MM32-NEXT:    addu16 $3, $2, $4
7490; MM32-NEXT:    sc $3, 0($1)
7491; MM32-NEXT:    beqzc $3, $BB18_1
7492; MM32-NEXT:  # %bb.2: # %entry
7493; MM32-NEXT:    jrc $ra
7494;
7495; O1-LABEL: AtomicLoadAdd32_OffGt9Bit:
7496; O1:       # %bb.0: # %entry
7497; O1-NEXT:    lui $2, %hi(_gp_disp)
7498; O1-NEXT:    addiu $2, $2, %lo(_gp_disp)
7499; O1-NEXT:    addu $1, $2, $25
7500; O1-NEXT:    lw $1, %got(x)($1)
7501; O1-NEXT:    addiu $1, $1, 1024
7502; O1-NEXT:  $BB18_1: # %entry
7503; O1-NEXT:    # =>This Inner Loop Header: Depth=1
7504; O1-NEXT:    ll $2, 0($1)
7505; O1-NEXT:    addu $3, $2, $4
7506; O1-NEXT:    sc $3, 0($1)
7507; O1-NEXT:    beqz $3, $BB18_1
7508; O1-NEXT:    nop
7509; O1-NEXT:  # %bb.2: # %entry
7510; O1-NEXT:    jr $ra
7511; O1-NEXT:    nop
7512;
7513; O2-LABEL: AtomicLoadAdd32_OffGt9Bit:
7514; O2:       # %bb.0: # %entry
7515; O2-NEXT:    lui $2, %hi(_gp_disp)
7516; O2-NEXT:    addiu $2, $2, %lo(_gp_disp)
7517; O2-NEXT:    addu $1, $2, $25
7518; O2-NEXT:    lw $1, %got(x)($1)
7519; O2-NEXT:    addiu $1, $1, 1024
7520; O2-NEXT:  $BB18_1: # %entry
7521; O2-NEXT:    # =>This Inner Loop Header: Depth=1
7522; O2-NEXT:    ll $2, 0($1)
7523; O2-NEXT:    addu $3, $2, $4
7524; O2-NEXT:    sc $3, 0($1)
7525; O2-NEXT:    beqz $3, $BB18_1
7526; O2-NEXT:    nop
7527; O2-NEXT:  # %bb.2: # %entry
7528; O2-NEXT:    jr $ra
7529; O2-NEXT:    nop
7530;
7531; O3-LABEL: AtomicLoadAdd32_OffGt9Bit:
7532; O3:       # %bb.0: # %entry
7533; O3-NEXT:    lui $2, %hi(_gp_disp)
7534; O3-NEXT:    addiu $2, $2, %lo(_gp_disp)
7535; O3-NEXT:    addu $1, $2, $25
7536; O3-NEXT:    lw $1, %got(x)($1)
7537; O3-NEXT:    addiu $1, $1, 1024
7538; O3-NEXT:  $BB18_1: # %entry
7539; O3-NEXT:    # =>This Inner Loop Header: Depth=1
7540; O3-NEXT:    ll $2, 0($1)
7541; O3-NEXT:    addu $3, $2, $4
7542; O3-NEXT:    sc $3, 0($1)
7543; O3-NEXT:    beqz $3, $BB18_1
7544; O3-NEXT:    nop
7545; O3-NEXT:  # %bb.2: # %entry
7546; O3-NEXT:    jr $ra
7547; O3-NEXT:    nop
7548;
7549; MIPS32EB-LABEL: AtomicLoadAdd32_OffGt9Bit:
7550; MIPS32EB:       # %bb.0: # %entry
7551; MIPS32EB-NEXT:    lui $2, %hi(_gp_disp)
7552; MIPS32EB-NEXT:    addiu $2, $2, %lo(_gp_disp)
7553; MIPS32EB-NEXT:    addu $1, $2, $25
7554; MIPS32EB-NEXT:    lw $1, %got(x)($1)
7555; MIPS32EB-NEXT:    addiu $1, $1, 1024
7556; MIPS32EB-NEXT:  $BB18_1: # %entry
7557; MIPS32EB-NEXT:    # =>This Inner Loop Header: Depth=1
7558; MIPS32EB-NEXT:    ll $2, 0($1)
7559; MIPS32EB-NEXT:    addu $3, $2, $4
7560; MIPS32EB-NEXT:    sc $3, 0($1)
7561; MIPS32EB-NEXT:    beqz $3, $BB18_1
7562; MIPS32EB-NEXT:    nop
7563; MIPS32EB-NEXT:  # %bb.2: # %entry
7564; MIPS32EB-NEXT:    jr $ra
7565; MIPS32EB-NEXT:    nop
7566entry:
7567  %0 = atomicrmw add i32* getelementptr(i32, i32* @x, i32 256), i32 %incr monotonic
7568  ret i32 %0
7569
7570}
7571