1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -march=mips -O0 -mcpu=mips32r2 -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=MIPS
3; RUN: llc -march=mips -O0 -mcpu=mips32r6 -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=MIPSR6
4; RUN: llc -march=mips -O0 -mcpu=mips32r2 -mattr=+micromips -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=MM
5; RUN: llc -march=mips -O0 -mcpu=mips32r6 -mattr=+micromips -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=MMR6
6; RUN: llc -march=mipsel -O0 -mcpu=mips32r2 -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=MIPSEL
7; RUN: llc -march=mipsel -O0 -mcpu=mips32r6 -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=MIPSELR6
8; RUN: llc -march=mipsel -O0 -mcpu=mips32r2 -mattr=+micromips -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=MMEL
9; RUN: llc -march=mipsel -O0 -mcpu=mips32r6 -mattr=+micromips -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=MMELR6
10; RUN: llc -march=mips64 -O0 -mcpu=mips64r2 -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=MIPS64
11; RUN: llc -march=mips64 -O0 -mcpu=mips64r6 -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=MIPS64R6
12; RUN: llc -march=mips64el -O0 -mcpu=mips64r2 -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=MIPS64EL
13; RUN: llc -march=mips64el -O0 -mcpu=mips64r6 -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=MIPS64ELR6
14
15define i32 @test_max_32(i32* nocapture %ptr, i32 signext %val) {
16; MIPS-LABEL: test_max_32:
17; MIPS:       # %bb.0: # %entry
18; MIPS-NEXT:    sync
19; MIPS-NEXT:  $BB0_1: # %entry
20; MIPS-NEXT:    # =>This Inner Loop Header: Depth=1
21; MIPS-NEXT:    ll $2, 0($4)
22; MIPS-NEXT:    slt $3, $2, $5
23; MIPS-NEXT:    move $1, $2
24; MIPS-NEXT:    movn $1, $5, $3
25; MIPS-NEXT:    sc $1, 0($4)
26; MIPS-NEXT:    beqz $1, $BB0_1
27; MIPS-NEXT:    nop
28; MIPS-NEXT:  # %bb.2: # %entry
29; MIPS-NEXT:    sync
30; MIPS-NEXT:    jr $ra
31; MIPS-NEXT:    nop
32;
33; MIPSR6-LABEL: test_max_32:
34; MIPSR6:       # %bb.0: # %entry
35; MIPSR6-NEXT:    sync
36; MIPSR6-NEXT:  $BB0_1: # %entry
37; MIPSR6-NEXT:    # =>This Inner Loop Header: Depth=1
38; MIPSR6-NEXT:    ll $2, 0($4)
39; MIPSR6-NEXT:    slt $3, $2, $5
40; MIPSR6-NEXT:    seleqz $1, $2, $3
41; MIPSR6-NEXT:    selnez $3, $5, $3
42; MIPSR6-NEXT:    or $1, $1, $3
43; MIPSR6-NEXT:    sc $1, 0($4)
44; MIPSR6-NEXT:    beqzc $1, $BB0_1
45; MIPSR6-NEXT:  # %bb.2: # %entry
46; MIPSR6-NEXT:    sync
47; MIPSR6-NEXT:    jrc $ra
48;
49; MM-LABEL: test_max_32:
50; MM:       # %bb.0: # %entry
51; MM-NEXT:    sync
52; MM-NEXT:  $BB0_1: # %entry
53; MM-NEXT:    # =>This Inner Loop Header: Depth=1
54; MM-NEXT:    ll $2, 0($4)
55; MM-NEXT:    slt $3, $2, $5
56; MM-NEXT:    or $1, $2, $zero
57; MM-NEXT:    movn $1, $5, $3
58; MM-NEXT:    sc $1, 0($4)
59; MM-NEXT:    beqzc $1, $BB0_1
60; MM-NEXT:  # %bb.2: # %entry
61; MM-NEXT:    sync
62; MM-NEXT:    jrc $ra
63;
64; MMR6-LABEL: test_max_32:
65; MMR6:       # %bb.0: # %entry
66; MMR6-NEXT:    sync
67; MMR6-NEXT:  $BB0_1: # %entry
68; MMR6-NEXT:    # =>This Inner Loop Header: Depth=1
69; MMR6-NEXT:    ll $2, 0($4)
70; MMR6-NEXT:    slt $3, $2, $5
71; MMR6-NEXT:    seleqz $1, $2, $3
72; MMR6-NEXT:    selnez $3, $5, $3
73; MMR6-NEXT:    or $1, $1, $3
74; MMR6-NEXT:    sc $1, 0($4)
75; MMR6-NEXT:    beqc $1, $zero, $BB0_1
76; MMR6-NEXT:  # %bb.2: # %entry
77; MMR6-NEXT:    sync
78; MMR6-NEXT:    jrc $ra
79;
80; MIPSEL-LABEL: test_max_32:
81; MIPSEL:       # %bb.0: # %entry
82; MIPSEL-NEXT:    sync
83; MIPSEL-NEXT:  $BB0_1: # %entry
84; MIPSEL-NEXT:    # =>This Inner Loop Header: Depth=1
85; MIPSEL-NEXT:    ll $2, 0($4)
86; MIPSEL-NEXT:    slt $3, $2, $5
87; MIPSEL-NEXT:    move $1, $2
88; MIPSEL-NEXT:    movn $1, $5, $3
89; MIPSEL-NEXT:    sc $1, 0($4)
90; MIPSEL-NEXT:    beqz $1, $BB0_1
91; MIPSEL-NEXT:    nop
92; MIPSEL-NEXT:  # %bb.2: # %entry
93; MIPSEL-NEXT:    sync
94; MIPSEL-NEXT:    jr $ra
95; MIPSEL-NEXT:    nop
96;
97; MIPSELR6-LABEL: test_max_32:
98; MIPSELR6:       # %bb.0: # %entry
99; MIPSELR6-NEXT:    sync
100; MIPSELR6-NEXT:  $BB0_1: # %entry
101; MIPSELR6-NEXT:    # =>This Inner Loop Header: Depth=1
102; MIPSELR6-NEXT:    ll $2, 0($4)
103; MIPSELR6-NEXT:    slt $3, $2, $5
104; MIPSELR6-NEXT:    seleqz $1, $2, $3
105; MIPSELR6-NEXT:    selnez $3, $5, $3
106; MIPSELR6-NEXT:    or $1, $1, $3
107; MIPSELR6-NEXT:    sc $1, 0($4)
108; MIPSELR6-NEXT:    beqzc $1, $BB0_1
109; MIPSELR6-NEXT:  # %bb.2: # %entry
110; MIPSELR6-NEXT:    sync
111; MIPSELR6-NEXT:    jrc $ra
112;
113; MMEL-LABEL: test_max_32:
114; MMEL:       # %bb.0: # %entry
115; MMEL-NEXT:    sync
116; MMEL-NEXT:  $BB0_1: # %entry
117; MMEL-NEXT:    # =>This Inner Loop Header: Depth=1
118; MMEL-NEXT:    ll $2, 0($4)
119; MMEL-NEXT:    slt $3, $2, $5
120; MMEL-NEXT:    or $1, $2, $zero
121; MMEL-NEXT:    movn $1, $5, $3
122; MMEL-NEXT:    sc $1, 0($4)
123; MMEL-NEXT:    beqzc $1, $BB0_1
124; MMEL-NEXT:  # %bb.2: # %entry
125; MMEL-NEXT:    sync
126; MMEL-NEXT:    jrc $ra
127;
128; MMELR6-LABEL: test_max_32:
129; MMELR6:       # %bb.0: # %entry
130; MMELR6-NEXT:    sync
131; MMELR6-NEXT:  $BB0_1: # %entry
132; MMELR6-NEXT:    # =>This Inner Loop Header: Depth=1
133; MMELR6-NEXT:    ll $2, 0($4)
134; MMELR6-NEXT:    slt $3, $2, $5
135; MMELR6-NEXT:    seleqz $1, $2, $3
136; MMELR6-NEXT:    selnez $3, $5, $3
137; MMELR6-NEXT:    or $1, $1, $3
138; MMELR6-NEXT:    sc $1, 0($4)
139; MMELR6-NEXT:    beqc $1, $zero, $BB0_1
140; MMELR6-NEXT:  # %bb.2: # %entry
141; MMELR6-NEXT:    sync
142; MMELR6-NEXT:    jrc $ra
143;
144; MIPS64-LABEL: test_max_32:
145; MIPS64:       # %bb.0: # %entry
146; MIPS64-NEXT:    # kill: def $a1 killed $a1 killed $a1_64
147; MIPS64-NEXT:    sync
148; MIPS64-NEXT:  .LBB0_1: # %entry
149; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
150; MIPS64-NEXT:    ll $2, 0($4)
151; MIPS64-NEXT:    slt $3, $2, $5
152; MIPS64-NEXT:    move $1, $2
153; MIPS64-NEXT:    movn $1, $5, $3
154; MIPS64-NEXT:    sc $1, 0($4)
155; MIPS64-NEXT:    beqz $1, .LBB0_1
156; MIPS64-NEXT:    nop
157; MIPS64-NEXT:  # %bb.2: # %entry
158; MIPS64-NEXT:    sync
159; MIPS64-NEXT:    jr $ra
160; MIPS64-NEXT:    nop
161;
162; MIPS64R6-LABEL: test_max_32:
163; MIPS64R6:       # %bb.0: # %entry
164; MIPS64R6-NEXT:    # kill: def $a1 killed $a1 killed $a1_64
165; MIPS64R6-NEXT:    sync
166; MIPS64R6-NEXT:  .LBB0_1: # %entry
167; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
168; MIPS64R6-NEXT:    ll $2, 0($4)
169; MIPS64R6-NEXT:    slt $3, $2, $5
170; MIPS64R6-NEXT:    seleqz $1, $2, $3
171; MIPS64R6-NEXT:    selnez $3, $5, $3
172; MIPS64R6-NEXT:    or $1, $1, $3
173; MIPS64R6-NEXT:    sc $1, 0($4)
174; MIPS64R6-NEXT:    beqzc $1, .LBB0_1
175; MIPS64R6-NEXT:  # %bb.2: # %entry
176; MIPS64R6-NEXT:    sync
177; MIPS64R6-NEXT:    jrc $ra
178;
179; MIPS64EL-LABEL: test_max_32:
180; MIPS64EL:       # %bb.0: # %entry
181; MIPS64EL-NEXT:    # kill: def $a1 killed $a1 killed $a1_64
182; MIPS64EL-NEXT:    sync
183; MIPS64EL-NEXT:  .LBB0_1: # %entry
184; MIPS64EL-NEXT:    # =>This Inner Loop Header: Depth=1
185; MIPS64EL-NEXT:    ll $2, 0($4)
186; MIPS64EL-NEXT:    slt $3, $2, $5
187; MIPS64EL-NEXT:    move $1, $2
188; MIPS64EL-NEXT:    movn $1, $5, $3
189; MIPS64EL-NEXT:    sc $1, 0($4)
190; MIPS64EL-NEXT:    beqz $1, .LBB0_1
191; MIPS64EL-NEXT:    nop
192; MIPS64EL-NEXT:  # %bb.2: # %entry
193; MIPS64EL-NEXT:    sync
194; MIPS64EL-NEXT:    jr $ra
195; MIPS64EL-NEXT:    nop
196;
197; MIPS64ELR6-LABEL: test_max_32:
198; MIPS64ELR6:       # %bb.0: # %entry
199; MIPS64ELR6-NEXT:    # kill: def $a1 killed $a1 killed $a1_64
200; MIPS64ELR6-NEXT:    sync
201; MIPS64ELR6-NEXT:  .LBB0_1: # %entry
202; MIPS64ELR6-NEXT:    # =>This Inner Loop Header: Depth=1
203; MIPS64ELR6-NEXT:    ll $2, 0($4)
204; MIPS64ELR6-NEXT:    slt $3, $2, $5
205; MIPS64ELR6-NEXT:    seleqz $1, $2, $3
206; MIPS64ELR6-NEXT:    selnez $3, $5, $3
207; MIPS64ELR6-NEXT:    or $1, $1, $3
208; MIPS64ELR6-NEXT:    sc $1, 0($4)
209; MIPS64ELR6-NEXT:    beqzc $1, .LBB0_1
210; MIPS64ELR6-NEXT:  # %bb.2: # %entry
211; MIPS64ELR6-NEXT:    sync
212; MIPS64ELR6-NEXT:    jrc $ra
213entry:
214  %0 = atomicrmw max i32* %ptr, i32 %val seq_cst
215  ret i32 %0
216}
217
218define i32 @test_min_32(i32* nocapture %ptr, i32 signext %val) {
219; MIPS-LABEL: test_min_32:
220; MIPS:       # %bb.0: # %entry
221; MIPS-NEXT:    sync
222; MIPS-NEXT:  $BB1_1: # %entry
223; MIPS-NEXT:    # =>This Inner Loop Header: Depth=1
224; MIPS-NEXT:    ll $2, 0($4)
225; MIPS-NEXT:    slt $3, $2, $5
226; MIPS-NEXT:    move $1, $2
227; MIPS-NEXT:    movz $1, $5, $3
228; MIPS-NEXT:    sc $1, 0($4)
229; MIPS-NEXT:    beqz $1, $BB1_1
230; MIPS-NEXT:    nop
231; MIPS-NEXT:  # %bb.2: # %entry
232; MIPS-NEXT:    sync
233; MIPS-NEXT:    jr $ra
234; MIPS-NEXT:    nop
235;
236; MIPSR6-LABEL: test_min_32:
237; MIPSR6:       # %bb.0: # %entry
238; MIPSR6-NEXT:    sync
239; MIPSR6-NEXT:  $BB1_1: # %entry
240; MIPSR6-NEXT:    # =>This Inner Loop Header: Depth=1
241; MIPSR6-NEXT:    ll $2, 0($4)
242; MIPSR6-NEXT:    slt $3, $2, $5
243; MIPSR6-NEXT:    selnez $1, $2, $3
244; MIPSR6-NEXT:    seleqz $3, $5, $3
245; MIPSR6-NEXT:    or $1, $1, $3
246; MIPSR6-NEXT:    sc $1, 0($4)
247; MIPSR6-NEXT:    beqzc $1, $BB1_1
248; MIPSR6-NEXT:  # %bb.2: # %entry
249; MIPSR6-NEXT:    sync
250; MIPSR6-NEXT:    jrc $ra
251;
252; MM-LABEL: test_min_32:
253; MM:       # %bb.0: # %entry
254; MM-NEXT:    sync
255; MM-NEXT:  $BB1_1: # %entry
256; MM-NEXT:    # =>This Inner Loop Header: Depth=1
257; MM-NEXT:    ll $2, 0($4)
258; MM-NEXT:    slt $3, $2, $5
259; MM-NEXT:    or $1, $2, $zero
260; MM-NEXT:    movz $1, $5, $3
261; MM-NEXT:    sc $1, 0($4)
262; MM-NEXT:    beqzc $1, $BB1_1
263; MM-NEXT:  # %bb.2: # %entry
264; MM-NEXT:    sync
265; MM-NEXT:    jrc $ra
266;
267; MMR6-LABEL: test_min_32:
268; MMR6:       # %bb.0: # %entry
269; MMR6-NEXT:    sync
270; MMR6-NEXT:  $BB1_1: # %entry
271; MMR6-NEXT:    # =>This Inner Loop Header: Depth=1
272; MMR6-NEXT:    ll $2, 0($4)
273; MMR6-NEXT:    slt $3, $2, $5
274; MMR6-NEXT:    selnez $1, $2, $3
275; MMR6-NEXT:    seleqz $3, $5, $3
276; MMR6-NEXT:    or $1, $1, $3
277; MMR6-NEXT:    sc $1, 0($4)
278; MMR6-NEXT:    beqc $1, $zero, $BB1_1
279; MMR6-NEXT:  # %bb.2: # %entry
280; MMR6-NEXT:    sync
281; MMR6-NEXT:    jrc $ra
282;
283; MIPSEL-LABEL: test_min_32:
284; MIPSEL:       # %bb.0: # %entry
285; MIPSEL-NEXT:    sync
286; MIPSEL-NEXT:  $BB1_1: # %entry
287; MIPSEL-NEXT:    # =>This Inner Loop Header: Depth=1
288; MIPSEL-NEXT:    ll $2, 0($4)
289; MIPSEL-NEXT:    slt $3, $2, $5
290; MIPSEL-NEXT:    move $1, $2
291; MIPSEL-NEXT:    movz $1, $5, $3
292; MIPSEL-NEXT:    sc $1, 0($4)
293; MIPSEL-NEXT:    beqz $1, $BB1_1
294; MIPSEL-NEXT:    nop
295; MIPSEL-NEXT:  # %bb.2: # %entry
296; MIPSEL-NEXT:    sync
297; MIPSEL-NEXT:    jr $ra
298; MIPSEL-NEXT:    nop
299;
300; MIPSELR6-LABEL: test_min_32:
301; MIPSELR6:       # %bb.0: # %entry
302; MIPSELR6-NEXT:    sync
303; MIPSELR6-NEXT:  $BB1_1: # %entry
304; MIPSELR6-NEXT:    # =>This Inner Loop Header: Depth=1
305; MIPSELR6-NEXT:    ll $2, 0($4)
306; MIPSELR6-NEXT:    slt $3, $2, $5
307; MIPSELR6-NEXT:    selnez $1, $2, $3
308; MIPSELR6-NEXT:    seleqz $3, $5, $3
309; MIPSELR6-NEXT:    or $1, $1, $3
310; MIPSELR6-NEXT:    sc $1, 0($4)
311; MIPSELR6-NEXT:    beqzc $1, $BB1_1
312; MIPSELR6-NEXT:  # %bb.2: # %entry
313; MIPSELR6-NEXT:    sync
314; MIPSELR6-NEXT:    jrc $ra
315;
316; MMEL-LABEL: test_min_32:
317; MMEL:       # %bb.0: # %entry
318; MMEL-NEXT:    sync
319; MMEL-NEXT:  $BB1_1: # %entry
320; MMEL-NEXT:    # =>This Inner Loop Header: Depth=1
321; MMEL-NEXT:    ll $2, 0($4)
322; MMEL-NEXT:    slt $3, $2, $5
323; MMEL-NEXT:    or $1, $2, $zero
324; MMEL-NEXT:    movz $1, $5, $3
325; MMEL-NEXT:    sc $1, 0($4)
326; MMEL-NEXT:    beqzc $1, $BB1_1
327; MMEL-NEXT:  # %bb.2: # %entry
328; MMEL-NEXT:    sync
329; MMEL-NEXT:    jrc $ra
330;
331; MMELR6-LABEL: test_min_32:
332; MMELR6:       # %bb.0: # %entry
333; MMELR6-NEXT:    sync
334; MMELR6-NEXT:  $BB1_1: # %entry
335; MMELR6-NEXT:    # =>This Inner Loop Header: Depth=1
336; MMELR6-NEXT:    ll $2, 0($4)
337; MMELR6-NEXT:    slt $3, $2, $5
338; MMELR6-NEXT:    selnez $1, $2, $3
339; MMELR6-NEXT:    seleqz $3, $5, $3
340; MMELR6-NEXT:    or $1, $1, $3
341; MMELR6-NEXT:    sc $1, 0($4)
342; MMELR6-NEXT:    beqc $1, $zero, $BB1_1
343; MMELR6-NEXT:  # %bb.2: # %entry
344; MMELR6-NEXT:    sync
345; MMELR6-NEXT:    jrc $ra
346;
347; MIPS64-LABEL: test_min_32:
348; MIPS64:       # %bb.0: # %entry
349; MIPS64-NEXT:    # kill: def $a1 killed $a1 killed $a1_64
350; MIPS64-NEXT:    sync
351; MIPS64-NEXT:  .LBB1_1: # %entry
352; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
353; MIPS64-NEXT:    ll $2, 0($4)
354; MIPS64-NEXT:    slt $3, $2, $5
355; MIPS64-NEXT:    move $1, $2
356; MIPS64-NEXT:    movz $1, $5, $3
357; MIPS64-NEXT:    sc $1, 0($4)
358; MIPS64-NEXT:    beqz $1, .LBB1_1
359; MIPS64-NEXT:    nop
360; MIPS64-NEXT:  # %bb.2: # %entry
361; MIPS64-NEXT:    sync
362; MIPS64-NEXT:    jr $ra
363; MIPS64-NEXT:    nop
364;
365; MIPS64R6-LABEL: test_min_32:
366; MIPS64R6:       # %bb.0: # %entry
367; MIPS64R6-NEXT:    # kill: def $a1 killed $a1 killed $a1_64
368; MIPS64R6-NEXT:    sync
369; MIPS64R6-NEXT:  .LBB1_1: # %entry
370; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
371; MIPS64R6-NEXT:    ll $2, 0($4)
372; MIPS64R6-NEXT:    slt $3, $2, $5
373; MIPS64R6-NEXT:    selnez $1, $2, $3
374; MIPS64R6-NEXT:    seleqz $3, $5, $3
375; MIPS64R6-NEXT:    or $1, $1, $3
376; MIPS64R6-NEXT:    sc $1, 0($4)
377; MIPS64R6-NEXT:    beqzc $1, .LBB1_1
378; MIPS64R6-NEXT:  # %bb.2: # %entry
379; MIPS64R6-NEXT:    sync
380; MIPS64R6-NEXT:    jrc $ra
381;
382; MIPS64EL-LABEL: test_min_32:
383; MIPS64EL:       # %bb.0: # %entry
384; MIPS64EL-NEXT:    # kill: def $a1 killed $a1 killed $a1_64
385; MIPS64EL-NEXT:    sync
386; MIPS64EL-NEXT:  .LBB1_1: # %entry
387; MIPS64EL-NEXT:    # =>This Inner Loop Header: Depth=1
388; MIPS64EL-NEXT:    ll $2, 0($4)
389; MIPS64EL-NEXT:    slt $3, $2, $5
390; MIPS64EL-NEXT:    move $1, $2
391; MIPS64EL-NEXT:    movz $1, $5, $3
392; MIPS64EL-NEXT:    sc $1, 0($4)
393; MIPS64EL-NEXT:    beqz $1, .LBB1_1
394; MIPS64EL-NEXT:    nop
395; MIPS64EL-NEXT:  # %bb.2: # %entry
396; MIPS64EL-NEXT:    sync
397; MIPS64EL-NEXT:    jr $ra
398; MIPS64EL-NEXT:    nop
399;
400; MIPS64ELR6-LABEL: test_min_32:
401; MIPS64ELR6:       # %bb.0: # %entry
402; MIPS64ELR6-NEXT:    # kill: def $a1 killed $a1 killed $a1_64
403; MIPS64ELR6-NEXT:    sync
404; MIPS64ELR6-NEXT:  .LBB1_1: # %entry
405; MIPS64ELR6-NEXT:    # =>This Inner Loop Header: Depth=1
406; MIPS64ELR6-NEXT:    ll $2, 0($4)
407; MIPS64ELR6-NEXT:    slt $3, $2, $5
408; MIPS64ELR6-NEXT:    selnez $1, $2, $3
409; MIPS64ELR6-NEXT:    seleqz $3, $5, $3
410; MIPS64ELR6-NEXT:    or $1, $1, $3
411; MIPS64ELR6-NEXT:    sc $1, 0($4)
412; MIPS64ELR6-NEXT:    beqzc $1, .LBB1_1
413; MIPS64ELR6-NEXT:  # %bb.2: # %entry
414; MIPS64ELR6-NEXT:    sync
415; MIPS64ELR6-NEXT:    jrc $ra
416entry:
417  %0 = atomicrmw min i32* %ptr, i32 %val seq_cst
418  ret i32 %0
419}
420
421define i32 @test_umax_32(i32* nocapture %ptr, i32 signext %val) {
422; MIPS-LABEL: test_umax_32:
423; MIPS:       # %bb.0: # %entry
424; MIPS-NEXT:    sync
425; MIPS-NEXT:  $BB2_1: # %entry
426; MIPS-NEXT:    # =>This Inner Loop Header: Depth=1
427; MIPS-NEXT:    ll $2, 0($4)
428; MIPS-NEXT:    sltu $3, $2, $5
429; MIPS-NEXT:    move $1, $2
430; MIPS-NEXT:    movn $1, $5, $3
431; MIPS-NEXT:    sc $1, 0($4)
432; MIPS-NEXT:    beqz $1, $BB2_1
433; MIPS-NEXT:    nop
434; MIPS-NEXT:  # %bb.2: # %entry
435; MIPS-NEXT:    sync
436; MIPS-NEXT:    jr $ra
437; MIPS-NEXT:    nop
438;
439; MIPSR6-LABEL: test_umax_32:
440; MIPSR6:       # %bb.0: # %entry
441; MIPSR6-NEXT:    sync
442; MIPSR6-NEXT:  $BB2_1: # %entry
443; MIPSR6-NEXT:    # =>This Inner Loop Header: Depth=1
444; MIPSR6-NEXT:    ll $2, 0($4)
445; MIPSR6-NEXT:    sltu $3, $2, $5
446; MIPSR6-NEXT:    seleqz $1, $2, $3
447; MIPSR6-NEXT:    selnez $3, $5, $3
448; MIPSR6-NEXT:    or $1, $1, $3
449; MIPSR6-NEXT:    sc $1, 0($4)
450; MIPSR6-NEXT:    beqzc $1, $BB2_1
451; MIPSR6-NEXT:  # %bb.2: # %entry
452; MIPSR6-NEXT:    sync
453; MIPSR6-NEXT:    jrc $ra
454;
455; MM-LABEL: test_umax_32:
456; MM:       # %bb.0: # %entry
457; MM-NEXT:    sync
458; MM-NEXT:  $BB2_1: # %entry
459; MM-NEXT:    # =>This Inner Loop Header: Depth=1
460; MM-NEXT:    ll $2, 0($4)
461; MM-NEXT:    sltu $3, $2, $5
462; MM-NEXT:    or $1, $2, $zero
463; MM-NEXT:    movn $1, $5, $3
464; MM-NEXT:    sc $1, 0($4)
465; MM-NEXT:    beqzc $1, $BB2_1
466; MM-NEXT:  # %bb.2: # %entry
467; MM-NEXT:    sync
468; MM-NEXT:    jrc $ra
469;
470; MMR6-LABEL: test_umax_32:
471; MMR6:       # %bb.0: # %entry
472; MMR6-NEXT:    sync
473; MMR6-NEXT:  $BB2_1: # %entry
474; MMR6-NEXT:    # =>This Inner Loop Header: Depth=1
475; MMR6-NEXT:    ll $2, 0($4)
476; MMR6-NEXT:    sltu $3, $2, $5
477; MMR6-NEXT:    seleqz $1, $2, $3
478; MMR6-NEXT:    selnez $3, $5, $3
479; MMR6-NEXT:    or $1, $1, $3
480; MMR6-NEXT:    sc $1, 0($4)
481; MMR6-NEXT:    beqc $1, $zero, $BB2_1
482; MMR6-NEXT:  # %bb.2: # %entry
483; MMR6-NEXT:    sync
484; MMR6-NEXT:    jrc $ra
485;
486; MIPSEL-LABEL: test_umax_32:
487; MIPSEL:       # %bb.0: # %entry
488; MIPSEL-NEXT:    sync
489; MIPSEL-NEXT:  $BB2_1: # %entry
490; MIPSEL-NEXT:    # =>This Inner Loop Header: Depth=1
491; MIPSEL-NEXT:    ll $2, 0($4)
492; MIPSEL-NEXT:    sltu $3, $2, $5
493; MIPSEL-NEXT:    move $1, $2
494; MIPSEL-NEXT:    movn $1, $5, $3
495; MIPSEL-NEXT:    sc $1, 0($4)
496; MIPSEL-NEXT:    beqz $1, $BB2_1
497; MIPSEL-NEXT:    nop
498; MIPSEL-NEXT:  # %bb.2: # %entry
499; MIPSEL-NEXT:    sync
500; MIPSEL-NEXT:    jr $ra
501; MIPSEL-NEXT:    nop
502;
503; MIPSELR6-LABEL: test_umax_32:
504; MIPSELR6:       # %bb.0: # %entry
505; MIPSELR6-NEXT:    sync
506; MIPSELR6-NEXT:  $BB2_1: # %entry
507; MIPSELR6-NEXT:    # =>This Inner Loop Header: Depth=1
508; MIPSELR6-NEXT:    ll $2, 0($4)
509; MIPSELR6-NEXT:    sltu $3, $2, $5
510; MIPSELR6-NEXT:    seleqz $1, $2, $3
511; MIPSELR6-NEXT:    selnez $3, $5, $3
512; MIPSELR6-NEXT:    or $1, $1, $3
513; MIPSELR6-NEXT:    sc $1, 0($4)
514; MIPSELR6-NEXT:    beqzc $1, $BB2_1
515; MIPSELR6-NEXT:  # %bb.2: # %entry
516; MIPSELR6-NEXT:    sync
517; MIPSELR6-NEXT:    jrc $ra
518;
519; MMEL-LABEL: test_umax_32:
520; MMEL:       # %bb.0: # %entry
521; MMEL-NEXT:    sync
522; MMEL-NEXT:  $BB2_1: # %entry
523; MMEL-NEXT:    # =>This Inner Loop Header: Depth=1
524; MMEL-NEXT:    ll $2, 0($4)
525; MMEL-NEXT:    sltu $3, $2, $5
526; MMEL-NEXT:    or $1, $2, $zero
527; MMEL-NEXT:    movn $1, $5, $3
528; MMEL-NEXT:    sc $1, 0($4)
529; MMEL-NEXT:    beqzc $1, $BB2_1
530; MMEL-NEXT:  # %bb.2: # %entry
531; MMEL-NEXT:    sync
532; MMEL-NEXT:    jrc $ra
533;
534; MMELR6-LABEL: test_umax_32:
535; MMELR6:       # %bb.0: # %entry
536; MMELR6-NEXT:    sync
537; MMELR6-NEXT:  $BB2_1: # %entry
538; MMELR6-NEXT:    # =>This Inner Loop Header: Depth=1
539; MMELR6-NEXT:    ll $2, 0($4)
540; MMELR6-NEXT:    sltu $3, $2, $5
541; MMELR6-NEXT:    seleqz $1, $2, $3
542; MMELR6-NEXT:    selnez $3, $5, $3
543; MMELR6-NEXT:    or $1, $1, $3
544; MMELR6-NEXT:    sc $1, 0($4)
545; MMELR6-NEXT:    beqc $1, $zero, $BB2_1
546; MMELR6-NEXT:  # %bb.2: # %entry
547; MMELR6-NEXT:    sync
548; MMELR6-NEXT:    jrc $ra
549;
550; MIPS64-LABEL: test_umax_32:
551; MIPS64:       # %bb.0: # %entry
552; MIPS64-NEXT:    # kill: def $a1 killed $a1 killed $a1_64
553; MIPS64-NEXT:    sync
554; MIPS64-NEXT:  .LBB2_1: # %entry
555; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
556; MIPS64-NEXT:    ll $2, 0($4)
557; MIPS64-NEXT:    sltu $3, $2, $5
558; MIPS64-NEXT:    move $1, $2
559; MIPS64-NEXT:    movn $1, $5, $3
560; MIPS64-NEXT:    sc $1, 0($4)
561; MIPS64-NEXT:    beqz $1, .LBB2_1
562; MIPS64-NEXT:    nop
563; MIPS64-NEXT:  # %bb.2: # %entry
564; MIPS64-NEXT:    sync
565; MIPS64-NEXT:    jr $ra
566; MIPS64-NEXT:    nop
567;
568; MIPS64R6-LABEL: test_umax_32:
569; MIPS64R6:       # %bb.0: # %entry
570; MIPS64R6-NEXT:    # kill: def $a1 killed $a1 killed $a1_64
571; MIPS64R6-NEXT:    sync
572; MIPS64R6-NEXT:  .LBB2_1: # %entry
573; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
574; MIPS64R6-NEXT:    ll $2, 0($4)
575; MIPS64R6-NEXT:    sltu $3, $2, $5
576; MIPS64R6-NEXT:    seleqz $1, $2, $3
577; MIPS64R6-NEXT:    selnez $3, $5, $3
578; MIPS64R6-NEXT:    or $1, $1, $3
579; MIPS64R6-NEXT:    sc $1, 0($4)
580; MIPS64R6-NEXT:    beqzc $1, .LBB2_1
581; MIPS64R6-NEXT:  # %bb.2: # %entry
582; MIPS64R6-NEXT:    sync
583; MIPS64R6-NEXT:    jrc $ra
584;
585; MIPS64EL-LABEL: test_umax_32:
586; MIPS64EL:       # %bb.0: # %entry
587; MIPS64EL-NEXT:    # kill: def $a1 killed $a1 killed $a1_64
588; MIPS64EL-NEXT:    sync
589; MIPS64EL-NEXT:  .LBB2_1: # %entry
590; MIPS64EL-NEXT:    # =>This Inner Loop Header: Depth=1
591; MIPS64EL-NEXT:    ll $2, 0($4)
592; MIPS64EL-NEXT:    sltu $3, $2, $5
593; MIPS64EL-NEXT:    move $1, $2
594; MIPS64EL-NEXT:    movn $1, $5, $3
595; MIPS64EL-NEXT:    sc $1, 0($4)
596; MIPS64EL-NEXT:    beqz $1, .LBB2_1
597; MIPS64EL-NEXT:    nop
598; MIPS64EL-NEXT:  # %bb.2: # %entry
599; MIPS64EL-NEXT:    sync
600; MIPS64EL-NEXT:    jr $ra
601; MIPS64EL-NEXT:    nop
602;
603; MIPS64ELR6-LABEL: test_umax_32:
604; MIPS64ELR6:       # %bb.0: # %entry
605; MIPS64ELR6-NEXT:    # kill: def $a1 killed $a1 killed $a1_64
606; MIPS64ELR6-NEXT:    sync
607; MIPS64ELR6-NEXT:  .LBB2_1: # %entry
608; MIPS64ELR6-NEXT:    # =>This Inner Loop Header: Depth=1
609; MIPS64ELR6-NEXT:    ll $2, 0($4)
610; MIPS64ELR6-NEXT:    sltu $3, $2, $5
611; MIPS64ELR6-NEXT:    seleqz $1, $2, $3
612; MIPS64ELR6-NEXT:    selnez $3, $5, $3
613; MIPS64ELR6-NEXT:    or $1, $1, $3
614; MIPS64ELR6-NEXT:    sc $1, 0($4)
615; MIPS64ELR6-NEXT:    beqzc $1, .LBB2_1
616; MIPS64ELR6-NEXT:  # %bb.2: # %entry
617; MIPS64ELR6-NEXT:    sync
618; MIPS64ELR6-NEXT:    jrc $ra
619entry:
620  %0 = atomicrmw umax i32* %ptr, i32 %val seq_cst
621  ret i32 %0
622}
623
624define i32 @test_umin_32(i32* nocapture %ptr, i32 signext %val) {
625; MIPS-LABEL: test_umin_32:
626; MIPS:       # %bb.0: # %entry
627; MIPS-NEXT:    sync
628; MIPS-NEXT:  $BB3_1: # %entry
629; MIPS-NEXT:    # =>This Inner Loop Header: Depth=1
630; MIPS-NEXT:    ll $2, 0($4)
631; MIPS-NEXT:    sltu $3, $2, $5
632; MIPS-NEXT:    move $1, $2
633; MIPS-NEXT:    movz $1, $5, $3
634; MIPS-NEXT:    sc $1, 0($4)
635; MIPS-NEXT:    beqz $1, $BB3_1
636; MIPS-NEXT:    nop
637; MIPS-NEXT:  # %bb.2: # %entry
638; MIPS-NEXT:    sync
639; MIPS-NEXT:    jr $ra
640; MIPS-NEXT:    nop
641;
642; MIPSR6-LABEL: test_umin_32:
643; MIPSR6:       # %bb.0: # %entry
644; MIPSR6-NEXT:    sync
645; MIPSR6-NEXT:  $BB3_1: # %entry
646; MIPSR6-NEXT:    # =>This Inner Loop Header: Depth=1
647; MIPSR6-NEXT:    ll $2, 0($4)
648; MIPSR6-NEXT:    sltu $3, $2, $5
649; MIPSR6-NEXT:    selnez $1, $2, $3
650; MIPSR6-NEXT:    seleqz $3, $5, $3
651; MIPSR6-NEXT:    or $1, $1, $3
652; MIPSR6-NEXT:    sc $1, 0($4)
653; MIPSR6-NEXT:    beqzc $1, $BB3_1
654; MIPSR6-NEXT:  # %bb.2: # %entry
655; MIPSR6-NEXT:    sync
656; MIPSR6-NEXT:    jrc $ra
657;
658; MM-LABEL: test_umin_32:
659; MM:       # %bb.0: # %entry
660; MM-NEXT:    sync
661; MM-NEXT:  $BB3_1: # %entry
662; MM-NEXT:    # =>This Inner Loop Header: Depth=1
663; MM-NEXT:    ll $2, 0($4)
664; MM-NEXT:    sltu $3, $2, $5
665; MM-NEXT:    or $1, $2, $zero
666; MM-NEXT:    movz $1, $5, $3
667; MM-NEXT:    sc $1, 0($4)
668; MM-NEXT:    beqzc $1, $BB3_1
669; MM-NEXT:  # %bb.2: # %entry
670; MM-NEXT:    sync
671; MM-NEXT:    jrc $ra
672;
673; MMR6-LABEL: test_umin_32:
674; MMR6:       # %bb.0: # %entry
675; MMR6-NEXT:    sync
676; MMR6-NEXT:  $BB3_1: # %entry
677; MMR6-NEXT:    # =>This Inner Loop Header: Depth=1
678; MMR6-NEXT:    ll $2, 0($4)
679; MMR6-NEXT:    sltu $3, $2, $5
680; MMR6-NEXT:    selnez $1, $2, $3
681; MMR6-NEXT:    seleqz $3, $5, $3
682; MMR6-NEXT:    or $1, $1, $3
683; MMR6-NEXT:    sc $1, 0($4)
684; MMR6-NEXT:    beqc $1, $zero, $BB3_1
685; MMR6-NEXT:  # %bb.2: # %entry
686; MMR6-NEXT:    sync
687; MMR6-NEXT:    jrc $ra
688;
689; MIPSEL-LABEL: test_umin_32:
690; MIPSEL:       # %bb.0: # %entry
691; MIPSEL-NEXT:    sync
692; MIPSEL-NEXT:  $BB3_1: # %entry
693; MIPSEL-NEXT:    # =>This Inner Loop Header: Depth=1
694; MIPSEL-NEXT:    ll $2, 0($4)
695; MIPSEL-NEXT:    sltu $3, $2, $5
696; MIPSEL-NEXT:    move $1, $2
697; MIPSEL-NEXT:    movz $1, $5, $3
698; MIPSEL-NEXT:    sc $1, 0($4)
699; MIPSEL-NEXT:    beqz $1, $BB3_1
700; MIPSEL-NEXT:    nop
701; MIPSEL-NEXT:  # %bb.2: # %entry
702; MIPSEL-NEXT:    sync
703; MIPSEL-NEXT:    jr $ra
704; MIPSEL-NEXT:    nop
705;
706; MIPSELR6-LABEL: test_umin_32:
707; MIPSELR6:       # %bb.0: # %entry
708; MIPSELR6-NEXT:    sync
709; MIPSELR6-NEXT:  $BB3_1: # %entry
710; MIPSELR6-NEXT:    # =>This Inner Loop Header: Depth=1
711; MIPSELR6-NEXT:    ll $2, 0($4)
712; MIPSELR6-NEXT:    sltu $3, $2, $5
713; MIPSELR6-NEXT:    selnez $1, $2, $3
714; MIPSELR6-NEXT:    seleqz $3, $5, $3
715; MIPSELR6-NEXT:    or $1, $1, $3
716; MIPSELR6-NEXT:    sc $1, 0($4)
717; MIPSELR6-NEXT:    beqzc $1, $BB3_1
718; MIPSELR6-NEXT:  # %bb.2: # %entry
719; MIPSELR6-NEXT:    sync
720; MIPSELR6-NEXT:    jrc $ra
721;
722; MMEL-LABEL: test_umin_32:
723; MMEL:       # %bb.0: # %entry
724; MMEL-NEXT:    sync
725; MMEL-NEXT:  $BB3_1: # %entry
726; MMEL-NEXT:    # =>This Inner Loop Header: Depth=1
727; MMEL-NEXT:    ll $2, 0($4)
728; MMEL-NEXT:    sltu $3, $2, $5
729; MMEL-NEXT:    or $1, $2, $zero
730; MMEL-NEXT:    movz $1, $5, $3
731; MMEL-NEXT:    sc $1, 0($4)
732; MMEL-NEXT:    beqzc $1, $BB3_1
733; MMEL-NEXT:  # %bb.2: # %entry
734; MMEL-NEXT:    sync
735; MMEL-NEXT:    jrc $ra
736;
737; MMELR6-LABEL: test_umin_32:
738; MMELR6:       # %bb.0: # %entry
739; MMELR6-NEXT:    sync
740; MMELR6-NEXT:  $BB3_1: # %entry
741; MMELR6-NEXT:    # =>This Inner Loop Header: Depth=1
742; MMELR6-NEXT:    ll $2, 0($4)
743; MMELR6-NEXT:    sltu $3, $2, $5
744; MMELR6-NEXT:    selnez $1, $2, $3
745; MMELR6-NEXT:    seleqz $3, $5, $3
746; MMELR6-NEXT:    or $1, $1, $3
747; MMELR6-NEXT:    sc $1, 0($4)
748; MMELR6-NEXT:    beqc $1, $zero, $BB3_1
749; MMELR6-NEXT:  # %bb.2: # %entry
750; MMELR6-NEXT:    sync
751; MMELR6-NEXT:    jrc $ra
752;
753; MIPS64-LABEL: test_umin_32:
754; MIPS64:       # %bb.0: # %entry
755; MIPS64-NEXT:    # kill: def $a1 killed $a1 killed $a1_64
756; MIPS64-NEXT:    sync
757; MIPS64-NEXT:  .LBB3_1: # %entry
758; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
759; MIPS64-NEXT:    ll $2, 0($4)
760; MIPS64-NEXT:    sltu $3, $2, $5
761; MIPS64-NEXT:    move $1, $2
762; MIPS64-NEXT:    movz $1, $5, $3
763; MIPS64-NEXT:    sc $1, 0($4)
764; MIPS64-NEXT:    beqz $1, .LBB3_1
765; MIPS64-NEXT:    nop
766; MIPS64-NEXT:  # %bb.2: # %entry
767; MIPS64-NEXT:    sync
768; MIPS64-NEXT:    jr $ra
769; MIPS64-NEXT:    nop
770;
771; MIPS64R6-LABEL: test_umin_32:
772; MIPS64R6:       # %bb.0: # %entry
773; MIPS64R6-NEXT:    # kill: def $a1 killed $a1 killed $a1_64
774; MIPS64R6-NEXT:    sync
775; MIPS64R6-NEXT:  .LBB3_1: # %entry
776; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
777; MIPS64R6-NEXT:    ll $2, 0($4)
778; MIPS64R6-NEXT:    sltu $3, $2, $5
779; MIPS64R6-NEXT:    selnez $1, $2, $3
780; MIPS64R6-NEXT:    seleqz $3, $5, $3
781; MIPS64R6-NEXT:    or $1, $1, $3
782; MIPS64R6-NEXT:    sc $1, 0($4)
783; MIPS64R6-NEXT:    beqzc $1, .LBB3_1
784; MIPS64R6-NEXT:  # %bb.2: # %entry
785; MIPS64R6-NEXT:    sync
786; MIPS64R6-NEXT:    jrc $ra
787;
788; MIPS64EL-LABEL: test_umin_32:
789; MIPS64EL:       # %bb.0: # %entry
790; MIPS64EL-NEXT:    # kill: def $a1 killed $a1 killed $a1_64
791; MIPS64EL-NEXT:    sync
792; MIPS64EL-NEXT:  .LBB3_1: # %entry
793; MIPS64EL-NEXT:    # =>This Inner Loop Header: Depth=1
794; MIPS64EL-NEXT:    ll $2, 0($4)
795; MIPS64EL-NEXT:    sltu $3, $2, $5
796; MIPS64EL-NEXT:    move $1, $2
797; MIPS64EL-NEXT:    movz $1, $5, $3
798; MIPS64EL-NEXT:    sc $1, 0($4)
799; MIPS64EL-NEXT:    beqz $1, .LBB3_1
800; MIPS64EL-NEXT:    nop
801; MIPS64EL-NEXT:  # %bb.2: # %entry
802; MIPS64EL-NEXT:    sync
803; MIPS64EL-NEXT:    jr $ra
804; MIPS64EL-NEXT:    nop
805;
806; MIPS64ELR6-LABEL: test_umin_32:
807; MIPS64ELR6:       # %bb.0: # %entry
808; MIPS64ELR6-NEXT:    # kill: def $a1 killed $a1 killed $a1_64
809; MIPS64ELR6-NEXT:    sync
810; MIPS64ELR6-NEXT:  .LBB3_1: # %entry
811; MIPS64ELR6-NEXT:    # =>This Inner Loop Header: Depth=1
812; MIPS64ELR6-NEXT:    ll $2, 0($4)
813; MIPS64ELR6-NEXT:    sltu $3, $2, $5
814; MIPS64ELR6-NEXT:    selnez $1, $2, $3
815; MIPS64ELR6-NEXT:    seleqz $3, $5, $3
816; MIPS64ELR6-NEXT:    or $1, $1, $3
817; MIPS64ELR6-NEXT:    sc $1, 0($4)
818; MIPS64ELR6-NEXT:    beqzc $1, .LBB3_1
819; MIPS64ELR6-NEXT:  # %bb.2: # %entry
820; MIPS64ELR6-NEXT:    sync
821; MIPS64ELR6-NEXT:    jrc $ra
822entry:
823  %0 = atomicrmw umin i32* %ptr, i32 %val seq_cst
824  ret i32 %0
825}
826
827define i16 @test_max_16(i16* nocapture %ptr, i16 signext %val) {
828; MIPS-LABEL: test_max_16:
829; MIPS:       # %bb.0: # %entry
830; MIPS-NEXT:    addiu $sp, $sp, -8
831; MIPS-NEXT:    .cfi_def_cfa_offset 8
832; MIPS-NEXT:    # kill: def $at killed $a1
833; MIPS-NEXT:    sync
834; MIPS-NEXT:    addiu $1, $zero, -4
835; MIPS-NEXT:    and $6, $4, $1
836; MIPS-NEXT:    andi $1, $4, 3
837; MIPS-NEXT:    xori $1, $1, 2
838; MIPS-NEXT:    sll $10, $1, 3
839; MIPS-NEXT:    ori $1, $zero, 65535
840; MIPS-NEXT:    sllv $8, $1, $10
841; MIPS-NEXT:    nor $9, $zero, $8
842; MIPS-NEXT:    sllv $7, $5, $10
843; MIPS-NEXT:  $BB4_1: # %entry
844; MIPS-NEXT:    # =>This Inner Loop Header: Depth=1
845; MIPS-NEXT:    ll $2, 0($6)
846; MIPS-NEXT:    slt $5, $2, $7
847; MIPS-NEXT:    move $3, $2
848; MIPS-NEXT:    movn $3, $7, $5
849; MIPS-NEXT:    and $3, $3, $8
850; MIPS-NEXT:    and $4, $2, $9
851; MIPS-NEXT:    or $4, $4, $3
852; MIPS-NEXT:    sc $4, 0($6)
853; MIPS-NEXT:    beqz $4, $BB4_1
854; MIPS-NEXT:    nop
855; MIPS-NEXT:  # %bb.2: # %entry
856; MIPS-NEXT:    and $1, $2, $8
857; MIPS-NEXT:    srlv $1, $1, $10
858; MIPS-NEXT:    seh $1, $1
859; MIPS-NEXT:  # %bb.3: # %entry
860; MIPS-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
861; MIPS-NEXT:  # %bb.4: # %entry
862; MIPS-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
863; MIPS-NEXT:    sync
864; MIPS-NEXT:    addiu $sp, $sp, 8
865; MIPS-NEXT:    jr $ra
866; MIPS-NEXT:    nop
867;
868; MIPSR6-LABEL: test_max_16:
869; MIPSR6:       # %bb.0: # %entry
870; MIPSR6-NEXT:    addiu $sp, $sp, -8
871; MIPSR6-NEXT:    .cfi_def_cfa_offset 8
872; MIPSR6-NEXT:    # kill: def $at killed $a1
873; MIPSR6-NEXT:    sync
874; MIPSR6-NEXT:    addiu $1, $zero, -4
875; MIPSR6-NEXT:    and $6, $4, $1
876; MIPSR6-NEXT:    andi $1, $4, 3
877; MIPSR6-NEXT:    xori $1, $1, 2
878; MIPSR6-NEXT:    sll $10, $1, 3
879; MIPSR6-NEXT:    ori $1, $zero, 65535
880; MIPSR6-NEXT:    sllv $8, $1, $10
881; MIPSR6-NEXT:    nor $9, $zero, $8
882; MIPSR6-NEXT:    sllv $7, $5, $10
883; MIPSR6-NEXT:  $BB4_1: # %entry
884; MIPSR6-NEXT:    # =>This Inner Loop Header: Depth=1
885; MIPSR6-NEXT:    ll $2, 0($6)
886; MIPSR6-NEXT:    slt $5, $2, $7
887; MIPSR6-NEXT:    seleqz $3, $2, $5
888; MIPSR6-NEXT:    selnez $5, $7, $5
889; MIPSR6-NEXT:    or $3, $3, $5
890; MIPSR6-NEXT:    and $3, $3, $8
891; MIPSR6-NEXT:    and $4, $2, $9
892; MIPSR6-NEXT:    or $4, $4, $3
893; MIPSR6-NEXT:    sc $4, 0($6)
894; MIPSR6-NEXT:    beqzc $4, $BB4_1
895; MIPSR6-NEXT:  # %bb.2: # %entry
896; MIPSR6-NEXT:    and $1, $2, $8
897; MIPSR6-NEXT:    srlv $1, $1, $10
898; MIPSR6-NEXT:    seh $1, $1
899; MIPSR6-NEXT:  # %bb.3: # %entry
900; MIPSR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
901; MIPSR6-NEXT:  # %bb.4: # %entry
902; MIPSR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
903; MIPSR6-NEXT:    sync
904; MIPSR6-NEXT:    addiu $sp, $sp, 8
905; MIPSR6-NEXT:    jrc $ra
906;
907; MM-LABEL: test_max_16:
908; MM:       # %bb.0: # %entry
909; MM-NEXT:    addiu $sp, $sp, -8
910; MM-NEXT:    .cfi_def_cfa_offset 8
911; MM-NEXT:    # kill: def $at killed $a1
912; MM-NEXT:    sync
913; MM-NEXT:    addiu $1, $zero, -4
914; MM-NEXT:    and $6, $4, $1
915; MM-NEXT:    andi $1, $4, 3
916; MM-NEXT:    xori $1, $1, 2
917; MM-NEXT:    sll $10, $1, 3
918; MM-NEXT:    ori $1, $zero, 65535
919; MM-NEXT:    sllv $8, $1, $10
920; MM-NEXT:    nor $9, $zero, $8
921; MM-NEXT:    sllv $7, $5, $10
922; MM-NEXT:  $BB4_1: # %entry
923; MM-NEXT:    # =>This Inner Loop Header: Depth=1
924; MM-NEXT:    ll $2, 0($6)
925; MM-NEXT:    slt $5, $2, $7
926; MM-NEXT:    or $3, $2, $zero
927; MM-NEXT:    movn $3, $7, $5
928; MM-NEXT:    and $3, $3, $8
929; MM-NEXT:    and $4, $2, $9
930; MM-NEXT:    or $4, $4, $3
931; MM-NEXT:    sc $4, 0($6)
932; MM-NEXT:    beqzc $4, $BB4_1
933; MM-NEXT:  # %bb.2: # %entry
934; MM-NEXT:    and $1, $2, $8
935; MM-NEXT:    srlv $1, $1, $10
936; MM-NEXT:    seh $1, $1
937; MM-NEXT:  # %bb.3: # %entry
938; MM-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
939; MM-NEXT:  # %bb.4: # %entry
940; MM-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
941; MM-NEXT:    sync
942; MM-NEXT:    addiusp 8
943; MM-NEXT:    jrc $ra
944;
945; MMR6-LABEL: test_max_16:
946; MMR6:       # %bb.0: # %entry
947; MMR6-NEXT:    addiu $sp, $sp, -8
948; MMR6-NEXT:    .cfi_def_cfa_offset 8
949; MMR6-NEXT:    # kill: def $at killed $a1
950; MMR6-NEXT:    sync
951; MMR6-NEXT:    addiu $1, $zero, -4
952; MMR6-NEXT:    and $6, $4, $1
953; MMR6-NEXT:    andi $1, $4, 3
954; MMR6-NEXT:    xori $1, $1, 2
955; MMR6-NEXT:    sll $10, $1, 3
956; MMR6-NEXT:    ori $1, $zero, 65535
957; MMR6-NEXT:    sllv $8, $1, $10
958; MMR6-NEXT:    nor $9, $zero, $8
959; MMR6-NEXT:    sllv $7, $5, $10
960; MMR6-NEXT:  $BB4_1: # %entry
961; MMR6-NEXT:    # =>This Inner Loop Header: Depth=1
962; MMR6-NEXT:    ll $2, 0($6)
963; MMR6-NEXT:    slt $5, $2, $7
964; MMR6-NEXT:    seleqz $3, $2, $5
965; MMR6-NEXT:    selnez $5, $7, $5
966; MMR6-NEXT:    or $3, $3, $5
967; MMR6-NEXT:    and $3, $3, $8
968; MMR6-NEXT:    and $4, $2, $9
969; MMR6-NEXT:    or $4, $4, $3
970; MMR6-NEXT:    sc $4, 0($6)
971; MMR6-NEXT:    beqc $4, $zero, $BB4_1
972; MMR6-NEXT:  # %bb.2: # %entry
973; MMR6-NEXT:    and $1, $2, $8
974; MMR6-NEXT:    srlv $1, $1, $10
975; MMR6-NEXT:    seh $1, $1
976; MMR6-NEXT:  # %bb.3: # %entry
977; MMR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
978; MMR6-NEXT:  # %bb.4: # %entry
979; MMR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
980; MMR6-NEXT:    sync
981; MMR6-NEXT:    addiu $sp, $sp, 8
982; MMR6-NEXT:    jrc $ra
983;
984; MIPSEL-LABEL: test_max_16:
985; MIPSEL:       # %bb.0: # %entry
986; MIPSEL-NEXT:    addiu $sp, $sp, -8
987; MIPSEL-NEXT:    .cfi_def_cfa_offset 8
988; MIPSEL-NEXT:    # kill: def $at killed $a1
989; MIPSEL-NEXT:    sync
990; MIPSEL-NEXT:    addiu $1, $zero, -4
991; MIPSEL-NEXT:    and $6, $4, $1
992; MIPSEL-NEXT:    andi $1, $4, 3
993; MIPSEL-NEXT:    sll $10, $1, 3
994; MIPSEL-NEXT:    ori $1, $zero, 65535
995; MIPSEL-NEXT:    sllv $8, $1, $10
996; MIPSEL-NEXT:    nor $9, $zero, $8
997; MIPSEL-NEXT:    sllv $7, $5, $10
998; MIPSEL-NEXT:  $BB4_1: # %entry
999; MIPSEL-NEXT:    # =>This Inner Loop Header: Depth=1
1000; MIPSEL-NEXT:    ll $2, 0($6)
1001; MIPSEL-NEXT:    and $2, $2, $8
1002; MIPSEL-NEXT:    and $7, $7, $8
1003; MIPSEL-NEXT:    slt $5, $2, $7
1004; MIPSEL-NEXT:    move $3, $2
1005; MIPSEL-NEXT:    movn $3, $7, $5
1006; MIPSEL-NEXT:    and $3, $3, $8
1007; MIPSEL-NEXT:    and $4, $2, $9
1008; MIPSEL-NEXT:    or $4, $4, $3
1009; MIPSEL-NEXT:    sc $4, 0($6)
1010; MIPSEL-NEXT:    beqz $4, $BB4_1
1011; MIPSEL-NEXT:    nop
1012; MIPSEL-NEXT:  # %bb.2: # %entry
1013; MIPSEL-NEXT:    and $1, $2, $8
1014; MIPSEL-NEXT:    srlv $1, $1, $10
1015; MIPSEL-NEXT:    seh $1, $1
1016; MIPSEL-NEXT:  # %bb.3: # %entry
1017; MIPSEL-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
1018; MIPSEL-NEXT:  # %bb.4: # %entry
1019; MIPSEL-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
1020; MIPSEL-NEXT:    sync
1021; MIPSEL-NEXT:    addiu $sp, $sp, 8
1022; MIPSEL-NEXT:    jr $ra
1023; MIPSEL-NEXT:    nop
1024;
1025; MIPSELR6-LABEL: test_max_16:
1026; MIPSELR6:       # %bb.0: # %entry
1027; MIPSELR6-NEXT:    addiu $sp, $sp, -8
1028; MIPSELR6-NEXT:    .cfi_def_cfa_offset 8
1029; MIPSELR6-NEXT:    # kill: def $at killed $a1
1030; MIPSELR6-NEXT:    sync
1031; MIPSELR6-NEXT:    addiu $1, $zero, -4
1032; MIPSELR6-NEXT:    and $6, $4, $1
1033; MIPSELR6-NEXT:    andi $1, $4, 3
1034; MIPSELR6-NEXT:    sll $10, $1, 3
1035; MIPSELR6-NEXT:    ori $1, $zero, 65535
1036; MIPSELR6-NEXT:    sllv $8, $1, $10
1037; MIPSELR6-NEXT:    nor $9, $zero, $8
1038; MIPSELR6-NEXT:    sllv $7, $5, $10
1039; MIPSELR6-NEXT:  $BB4_1: # %entry
1040; MIPSELR6-NEXT:    # =>This Inner Loop Header: Depth=1
1041; MIPSELR6-NEXT:    ll $2, 0($6)
1042; MIPSELR6-NEXT:    and $2, $2, $8
1043; MIPSELR6-NEXT:    and $7, $7, $8
1044; MIPSELR6-NEXT:    slt $5, $2, $7
1045; MIPSELR6-NEXT:    seleqz $3, $2, $5
1046; MIPSELR6-NEXT:    selnez $5, $7, $5
1047; MIPSELR6-NEXT:    or $3, $3, $5
1048; MIPSELR6-NEXT:    and $3, $3, $8
1049; MIPSELR6-NEXT:    and $4, $2, $9
1050; MIPSELR6-NEXT:    or $4, $4, $3
1051; MIPSELR6-NEXT:    sc $4, 0($6)
1052; MIPSELR6-NEXT:    beqzc $4, $BB4_1
1053; MIPSELR6-NEXT:  # %bb.2: # %entry
1054; MIPSELR6-NEXT:    and $1, $2, $8
1055; MIPSELR6-NEXT:    srlv $1, $1, $10
1056; MIPSELR6-NEXT:    seh $1, $1
1057; MIPSELR6-NEXT:  # %bb.3: # %entry
1058; MIPSELR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
1059; MIPSELR6-NEXT:  # %bb.4: # %entry
1060; MIPSELR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
1061; MIPSELR6-NEXT:    sync
1062; MIPSELR6-NEXT:    addiu $sp, $sp, 8
1063; MIPSELR6-NEXT:    jrc $ra
1064;
1065; MMEL-LABEL: test_max_16:
1066; MMEL:       # %bb.0: # %entry
1067; MMEL-NEXT:    addiu $sp, $sp, -8
1068; MMEL-NEXT:    .cfi_def_cfa_offset 8
1069; MMEL-NEXT:    # kill: def $at killed $a1
1070; MMEL-NEXT:    sync
1071; MMEL-NEXT:    addiu $1, $zero, -4
1072; MMEL-NEXT:    and $6, $4, $1
1073; MMEL-NEXT:    andi $1, $4, 3
1074; MMEL-NEXT:    sll $10, $1, 3
1075; MMEL-NEXT:    ori $1, $zero, 65535
1076; MMEL-NEXT:    sllv $8, $1, $10
1077; MMEL-NEXT:    nor $9, $zero, $8
1078; MMEL-NEXT:    sllv $7, $5, $10
1079; MMEL-NEXT:  $BB4_1: # %entry
1080; MMEL-NEXT:    # =>This Inner Loop Header: Depth=1
1081; MMEL-NEXT:    ll $2, 0($6)
1082; MMEL-NEXT:    and $2, $2, $8
1083; MMEL-NEXT:    and $7, $7, $8
1084; MMEL-NEXT:    slt $5, $2, $7
1085; MMEL-NEXT:    or $3, $2, $zero
1086; MMEL-NEXT:    movn $3, $7, $5
1087; MMEL-NEXT:    and $3, $3, $8
1088; MMEL-NEXT:    and $4, $2, $9
1089; MMEL-NEXT:    or $4, $4, $3
1090; MMEL-NEXT:    sc $4, 0($6)
1091; MMEL-NEXT:    beqzc $4, $BB4_1
1092; MMEL-NEXT:  # %bb.2: # %entry
1093; MMEL-NEXT:    and $1, $2, $8
1094; MMEL-NEXT:    srlv $1, $1, $10
1095; MMEL-NEXT:    seh $1, $1
1096; MMEL-NEXT:  # %bb.3: # %entry
1097; MMEL-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
1098; MMEL-NEXT:  # %bb.4: # %entry
1099; MMEL-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
1100; MMEL-NEXT:    sync
1101; MMEL-NEXT:    addiusp 8
1102; MMEL-NEXT:    jrc $ra
1103;
1104; MMELR6-LABEL: test_max_16:
1105; MMELR6:       # %bb.0: # %entry
1106; MMELR6-NEXT:    addiu $sp, $sp, -8
1107; MMELR6-NEXT:    .cfi_def_cfa_offset 8
1108; MMELR6-NEXT:    # kill: def $at killed $a1
1109; MMELR6-NEXT:    sync
1110; MMELR6-NEXT:    addiu $1, $zero, -4
1111; MMELR6-NEXT:    and $6, $4, $1
1112; MMELR6-NEXT:    andi $1, $4, 3
1113; MMELR6-NEXT:    sll $10, $1, 3
1114; MMELR6-NEXT:    ori $1, $zero, 65535
1115; MMELR6-NEXT:    sllv $8, $1, $10
1116; MMELR6-NEXT:    nor $9, $zero, $8
1117; MMELR6-NEXT:    sllv $7, $5, $10
1118; MMELR6-NEXT:  $BB4_1: # %entry
1119; MMELR6-NEXT:    # =>This Inner Loop Header: Depth=1
1120; MMELR6-NEXT:    ll $2, 0($6)
1121; MMELR6-NEXT:    and $2, $2, $8
1122; MMELR6-NEXT:    and $7, $7, $8
1123; MMELR6-NEXT:    slt $5, $2, $7
1124; MMELR6-NEXT:    seleqz $3, $2, $5
1125; MMELR6-NEXT:    selnez $5, $7, $5
1126; MMELR6-NEXT:    or $3, $3, $5
1127; MMELR6-NEXT:    and $3, $3, $8
1128; MMELR6-NEXT:    and $4, $2, $9
1129; MMELR6-NEXT:    or $4, $4, $3
1130; MMELR6-NEXT:    sc $4, 0($6)
1131; MMELR6-NEXT:    beqc $4, $zero, $BB4_1
1132; MMELR6-NEXT:  # %bb.2: # %entry
1133; MMELR6-NEXT:    and $1, $2, $8
1134; MMELR6-NEXT:    srlv $1, $1, $10
1135; MMELR6-NEXT:    seh $1, $1
1136; MMELR6-NEXT:  # %bb.3: # %entry
1137; MMELR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
1138; MMELR6-NEXT:  # %bb.4: # %entry
1139; MMELR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
1140; MMELR6-NEXT:    sync
1141; MMELR6-NEXT:    addiu $sp, $sp, 8
1142; MMELR6-NEXT:    jrc $ra
1143;
1144; MIPS64-LABEL: test_max_16:
1145; MIPS64:       # %bb.0: # %entry
1146; MIPS64-NEXT:    daddiu $sp, $sp, -16
1147; MIPS64-NEXT:    .cfi_def_cfa_offset 16
1148; MIPS64-NEXT:    move $1, $5
1149; MIPS64-NEXT:    sync
1150; MIPS64-NEXT:    daddiu $2, $zero, -4
1151; MIPS64-NEXT:    and $6, $4, $2
1152; MIPS64-NEXT:    andi $2, $4, 3
1153; MIPS64-NEXT:    xori $2, $2, 2
1154; MIPS64-NEXT:    sll $10, $2, 3
1155; MIPS64-NEXT:    ori $2, $zero, 65535
1156; MIPS64-NEXT:    sllv $8, $2, $10
1157; MIPS64-NEXT:    nor $9, $zero, $8
1158; MIPS64-NEXT:    sllv $7, $1, $10
1159; MIPS64-NEXT:  .LBB4_1: # %entry
1160; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
1161; MIPS64-NEXT:    ll $2, 0($6)
1162; MIPS64-NEXT:    slt $5, $2, $7
1163; MIPS64-NEXT:    move $3, $2
1164; MIPS64-NEXT:    movn $3, $7, $5
1165; MIPS64-NEXT:    and $3, $3, $8
1166; MIPS64-NEXT:    and $4, $2, $9
1167; MIPS64-NEXT:    or $4, $4, $3
1168; MIPS64-NEXT:    sc $4, 0($6)
1169; MIPS64-NEXT:    beqz $4, .LBB4_1
1170; MIPS64-NEXT:    nop
1171; MIPS64-NEXT:  # %bb.2: # %entry
1172; MIPS64-NEXT:    and $1, $2, $8
1173; MIPS64-NEXT:    srlv $1, $1, $10
1174; MIPS64-NEXT:    seh $1, $1
1175; MIPS64-NEXT:  # %bb.3: # %entry
1176; MIPS64-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
1177; MIPS64-NEXT:  # %bb.4: # %entry
1178; MIPS64-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
1179; MIPS64-NEXT:    sync
1180; MIPS64-NEXT:    daddiu $sp, $sp, 16
1181; MIPS64-NEXT:    jr $ra
1182; MIPS64-NEXT:    nop
1183;
1184; MIPS64R6-LABEL: test_max_16:
1185; MIPS64R6:       # %bb.0: # %entry
1186; MIPS64R6-NEXT:    daddiu $sp, $sp, -16
1187; MIPS64R6-NEXT:    .cfi_def_cfa_offset 16
1188; MIPS64R6-NEXT:    move $1, $5
1189; MIPS64R6-NEXT:    sync
1190; MIPS64R6-NEXT:    daddiu $2, $zero, -4
1191; MIPS64R6-NEXT:    and $6, $4, $2
1192; MIPS64R6-NEXT:    andi $2, $4, 3
1193; MIPS64R6-NEXT:    xori $2, $2, 2
1194; MIPS64R6-NEXT:    sll $10, $2, 3
1195; MIPS64R6-NEXT:    ori $2, $zero, 65535
1196; MIPS64R6-NEXT:    sllv $8, $2, $10
1197; MIPS64R6-NEXT:    nor $9, $zero, $8
1198; MIPS64R6-NEXT:    sllv $7, $1, $10
1199; MIPS64R6-NEXT:  .LBB4_1: # %entry
1200; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
1201; MIPS64R6-NEXT:    ll $2, 0($6)
1202; MIPS64R6-NEXT:    slt $5, $2, $7
1203; MIPS64R6-NEXT:    seleqz $3, $2, $5
1204; MIPS64R6-NEXT:    selnez $5, $7, $5
1205; MIPS64R6-NEXT:    or $3, $3, $5
1206; MIPS64R6-NEXT:    and $3, $3, $8
1207; MIPS64R6-NEXT:    and $4, $2, $9
1208; MIPS64R6-NEXT:    or $4, $4, $3
1209; MIPS64R6-NEXT:    sc $4, 0($6)
1210; MIPS64R6-NEXT:    beqzc $4, .LBB4_1
1211; MIPS64R6-NEXT:  # %bb.2: # %entry
1212; MIPS64R6-NEXT:    and $1, $2, $8
1213; MIPS64R6-NEXT:    srlv $1, $1, $10
1214; MIPS64R6-NEXT:    seh $1, $1
1215; MIPS64R6-NEXT:  # %bb.3: # %entry
1216; MIPS64R6-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
1217; MIPS64R6-NEXT:  # %bb.4: # %entry
1218; MIPS64R6-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
1219; MIPS64R6-NEXT:    sync
1220; MIPS64R6-NEXT:    daddiu $sp, $sp, 16
1221; MIPS64R6-NEXT:    jrc $ra
1222;
1223; MIPS64EL-LABEL: test_max_16:
1224; MIPS64EL:       # %bb.0: # %entry
1225; MIPS64EL-NEXT:    daddiu $sp, $sp, -16
1226; MIPS64EL-NEXT:    .cfi_def_cfa_offset 16
1227; MIPS64EL-NEXT:    move $1, $5
1228; MIPS64EL-NEXT:    sync
1229; MIPS64EL-NEXT:    daddiu $2, $zero, -4
1230; MIPS64EL-NEXT:    and $6, $4, $2
1231; MIPS64EL-NEXT:    andi $2, $4, 3
1232; MIPS64EL-NEXT:    sll $10, $2, 3
1233; MIPS64EL-NEXT:    ori $2, $zero, 65535
1234; MIPS64EL-NEXT:    sllv $8, $2, $10
1235; MIPS64EL-NEXT:    nor $9, $zero, $8
1236; MIPS64EL-NEXT:    sllv $7, $1, $10
1237; MIPS64EL-NEXT:  .LBB4_1: # %entry
1238; MIPS64EL-NEXT:    # =>This Inner Loop Header: Depth=1
1239; MIPS64EL-NEXT:    ll $2, 0($6)
1240; MIPS64EL-NEXT:    and $2, $2, $8
1241; MIPS64EL-NEXT:    and $7, $7, $8
1242; MIPS64EL-NEXT:    slt $5, $2, $7
1243; MIPS64EL-NEXT:    move $3, $2
1244; MIPS64EL-NEXT:    movn $3, $7, $5
1245; MIPS64EL-NEXT:    and $3, $3, $8
1246; MIPS64EL-NEXT:    and $4, $2, $9
1247; MIPS64EL-NEXT:    or $4, $4, $3
1248; MIPS64EL-NEXT:    sc $4, 0($6)
1249; MIPS64EL-NEXT:    beqz $4, .LBB4_1
1250; MIPS64EL-NEXT:    nop
1251; MIPS64EL-NEXT:  # %bb.2: # %entry
1252; MIPS64EL-NEXT:    and $1, $2, $8
1253; MIPS64EL-NEXT:    srlv $1, $1, $10
1254; MIPS64EL-NEXT:    seh $1, $1
1255; MIPS64EL-NEXT:  # %bb.3: # %entry
1256; MIPS64EL-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
1257; MIPS64EL-NEXT:  # %bb.4: # %entry
1258; MIPS64EL-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
1259; MIPS64EL-NEXT:    sync
1260; MIPS64EL-NEXT:    daddiu $sp, $sp, 16
1261; MIPS64EL-NEXT:    jr $ra
1262; MIPS64EL-NEXT:    nop
1263;
1264; MIPS64ELR6-LABEL: test_max_16:
1265; MIPS64ELR6:       # %bb.0: # %entry
1266; MIPS64ELR6-NEXT:    daddiu $sp, $sp, -16
1267; MIPS64ELR6-NEXT:    .cfi_def_cfa_offset 16
1268; MIPS64ELR6-NEXT:    move $1, $5
1269; MIPS64ELR6-NEXT:    sync
1270; MIPS64ELR6-NEXT:    daddiu $2, $zero, -4
1271; MIPS64ELR6-NEXT:    and $6, $4, $2
1272; MIPS64ELR6-NEXT:    andi $2, $4, 3
1273; MIPS64ELR6-NEXT:    sll $10, $2, 3
1274; MIPS64ELR6-NEXT:    ori $2, $zero, 65535
1275; MIPS64ELR6-NEXT:    sllv $8, $2, $10
1276; MIPS64ELR6-NEXT:    nor $9, $zero, $8
1277; MIPS64ELR6-NEXT:    sllv $7, $1, $10
1278; MIPS64ELR6-NEXT:  .LBB4_1: # %entry
1279; MIPS64ELR6-NEXT:    # =>This Inner Loop Header: Depth=1
1280; MIPS64ELR6-NEXT:    ll $2, 0($6)
1281; MIPS64ELR6-NEXT:    and $2, $2, $8
1282; MIPS64ELR6-NEXT:    and $7, $7, $8
1283; MIPS64ELR6-NEXT:    slt $5, $2, $7
1284; MIPS64ELR6-NEXT:    seleqz $3, $2, $5
1285; MIPS64ELR6-NEXT:    selnez $5, $7, $5
1286; MIPS64ELR6-NEXT:    or $3, $3, $5
1287; MIPS64ELR6-NEXT:    and $3, $3, $8
1288; MIPS64ELR6-NEXT:    and $4, $2, $9
1289; MIPS64ELR6-NEXT:    or $4, $4, $3
1290; MIPS64ELR6-NEXT:    sc $4, 0($6)
1291; MIPS64ELR6-NEXT:    beqzc $4, .LBB4_1
1292; MIPS64ELR6-NEXT:  # %bb.2: # %entry
1293; MIPS64ELR6-NEXT:    and $1, $2, $8
1294; MIPS64ELR6-NEXT:    srlv $1, $1, $10
1295; MIPS64ELR6-NEXT:    seh $1, $1
1296; MIPS64ELR6-NEXT:  # %bb.3: # %entry
1297; MIPS64ELR6-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
1298; MIPS64ELR6-NEXT:  # %bb.4: # %entry
1299; MIPS64ELR6-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
1300; MIPS64ELR6-NEXT:    sync
1301; MIPS64ELR6-NEXT:    daddiu $sp, $sp, 16
1302; MIPS64ELR6-NEXT:    jrc $ra
1303entry:
1304  %0 = atomicrmw max i16* %ptr, i16 %val seq_cst
1305  ret i16 %0
1306}
1307
1308define i16 @test_min_16(i16* nocapture %ptr, i16 signext %val) {
1309; MIPS-LABEL: test_min_16:
1310; MIPS:       # %bb.0: # %entry
1311; MIPS-NEXT:    addiu $sp, $sp, -8
1312; MIPS-NEXT:    .cfi_def_cfa_offset 8
1313; MIPS-NEXT:    # kill: def $at killed $a1
1314; MIPS-NEXT:    sync
1315; MIPS-NEXT:    addiu $1, $zero, -4
1316; MIPS-NEXT:    and $6, $4, $1
1317; MIPS-NEXT:    andi $1, $4, 3
1318; MIPS-NEXT:    xori $1, $1, 2
1319; MIPS-NEXT:    sll $10, $1, 3
1320; MIPS-NEXT:    ori $1, $zero, 65535
1321; MIPS-NEXT:    sllv $8, $1, $10
1322; MIPS-NEXT:    nor $9, $zero, $8
1323; MIPS-NEXT:    sllv $7, $5, $10
1324; MIPS-NEXT:  $BB5_1: # %entry
1325; MIPS-NEXT:    # =>This Inner Loop Header: Depth=1
1326; MIPS-NEXT:    ll $2, 0($6)
1327; MIPS-NEXT:    slt $5, $2, $7
1328; MIPS-NEXT:    move $3, $2
1329; MIPS-NEXT:    movz $3, $7, $5
1330; MIPS-NEXT:    and $3, $3, $8
1331; MIPS-NEXT:    and $4, $2, $9
1332; MIPS-NEXT:    or $4, $4, $3
1333; MIPS-NEXT:    sc $4, 0($6)
1334; MIPS-NEXT:    beqz $4, $BB5_1
1335; MIPS-NEXT:    nop
1336; MIPS-NEXT:  # %bb.2: # %entry
1337; MIPS-NEXT:    and $1, $2, $8
1338; MIPS-NEXT:    srlv $1, $1, $10
1339; MIPS-NEXT:    seh $1, $1
1340; MIPS-NEXT:  # %bb.3: # %entry
1341; MIPS-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
1342; MIPS-NEXT:  # %bb.4: # %entry
1343; MIPS-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
1344; MIPS-NEXT:    sync
1345; MIPS-NEXT:    addiu $sp, $sp, 8
1346; MIPS-NEXT:    jr $ra
1347; MIPS-NEXT:    nop
1348;
1349; MIPSR6-LABEL: test_min_16:
1350; MIPSR6:       # %bb.0: # %entry
1351; MIPSR6-NEXT:    addiu $sp, $sp, -8
1352; MIPSR6-NEXT:    .cfi_def_cfa_offset 8
1353; MIPSR6-NEXT:    # kill: def $at killed $a1
1354; MIPSR6-NEXT:    sync
1355; MIPSR6-NEXT:    addiu $1, $zero, -4
1356; MIPSR6-NEXT:    and $6, $4, $1
1357; MIPSR6-NEXT:    andi $1, $4, 3
1358; MIPSR6-NEXT:    xori $1, $1, 2
1359; MIPSR6-NEXT:    sll $10, $1, 3
1360; MIPSR6-NEXT:    ori $1, $zero, 65535
1361; MIPSR6-NEXT:    sllv $8, $1, $10
1362; MIPSR6-NEXT:    nor $9, $zero, $8
1363; MIPSR6-NEXT:    sllv $7, $5, $10
1364; MIPSR6-NEXT:  $BB5_1: # %entry
1365; MIPSR6-NEXT:    # =>This Inner Loop Header: Depth=1
1366; MIPSR6-NEXT:    ll $2, 0($6)
1367; MIPSR6-NEXT:    slt $5, $2, $7
1368; MIPSR6-NEXT:    selnez $3, $2, $5
1369; MIPSR6-NEXT:    seleqz $5, $7, $5
1370; MIPSR6-NEXT:    or $3, $3, $5
1371; MIPSR6-NEXT:    and $3, $3, $8
1372; MIPSR6-NEXT:    and $4, $2, $9
1373; MIPSR6-NEXT:    or $4, $4, $3
1374; MIPSR6-NEXT:    sc $4, 0($6)
1375; MIPSR6-NEXT:    beqzc $4, $BB5_1
1376; MIPSR6-NEXT:  # %bb.2: # %entry
1377; MIPSR6-NEXT:    and $1, $2, $8
1378; MIPSR6-NEXT:    srlv $1, $1, $10
1379; MIPSR6-NEXT:    seh $1, $1
1380; MIPSR6-NEXT:  # %bb.3: # %entry
1381; MIPSR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
1382; MIPSR6-NEXT:  # %bb.4: # %entry
1383; MIPSR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
1384; MIPSR6-NEXT:    sync
1385; MIPSR6-NEXT:    addiu $sp, $sp, 8
1386; MIPSR6-NEXT:    jrc $ra
1387;
1388; MM-LABEL: test_min_16:
1389; MM:       # %bb.0: # %entry
1390; MM-NEXT:    addiu $sp, $sp, -8
1391; MM-NEXT:    .cfi_def_cfa_offset 8
1392; MM-NEXT:    # kill: def $at killed $a1
1393; MM-NEXT:    sync
1394; MM-NEXT:    addiu $1, $zero, -4
1395; MM-NEXT:    and $6, $4, $1
1396; MM-NEXT:    andi $1, $4, 3
1397; MM-NEXT:    xori $1, $1, 2
1398; MM-NEXT:    sll $10, $1, 3
1399; MM-NEXT:    ori $1, $zero, 65535
1400; MM-NEXT:    sllv $8, $1, $10
1401; MM-NEXT:    nor $9, $zero, $8
1402; MM-NEXT:    sllv $7, $5, $10
1403; MM-NEXT:  $BB5_1: # %entry
1404; MM-NEXT:    # =>This Inner Loop Header: Depth=1
1405; MM-NEXT:    ll $2, 0($6)
1406; MM-NEXT:    slt $5, $2, $7
1407; MM-NEXT:    or $3, $2, $zero
1408; MM-NEXT:    movz $3, $7, $5
1409; MM-NEXT:    and $3, $3, $8
1410; MM-NEXT:    and $4, $2, $9
1411; MM-NEXT:    or $4, $4, $3
1412; MM-NEXT:    sc $4, 0($6)
1413; MM-NEXT:    beqzc $4, $BB5_1
1414; MM-NEXT:  # %bb.2: # %entry
1415; MM-NEXT:    and $1, $2, $8
1416; MM-NEXT:    srlv $1, $1, $10
1417; MM-NEXT:    seh $1, $1
1418; MM-NEXT:  # %bb.3: # %entry
1419; MM-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
1420; MM-NEXT:  # %bb.4: # %entry
1421; MM-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
1422; MM-NEXT:    sync
1423; MM-NEXT:    addiusp 8
1424; MM-NEXT:    jrc $ra
1425;
1426; MMR6-LABEL: test_min_16:
1427; MMR6:       # %bb.0: # %entry
1428; MMR6-NEXT:    addiu $sp, $sp, -8
1429; MMR6-NEXT:    .cfi_def_cfa_offset 8
1430; MMR6-NEXT:    # kill: def $at killed $a1
1431; MMR6-NEXT:    sync
1432; MMR6-NEXT:    addiu $1, $zero, -4
1433; MMR6-NEXT:    and $6, $4, $1
1434; MMR6-NEXT:    andi $1, $4, 3
1435; MMR6-NEXT:    xori $1, $1, 2
1436; MMR6-NEXT:    sll $10, $1, 3
1437; MMR6-NEXT:    ori $1, $zero, 65535
1438; MMR6-NEXT:    sllv $8, $1, $10
1439; MMR6-NEXT:    nor $9, $zero, $8
1440; MMR6-NEXT:    sllv $7, $5, $10
1441; MMR6-NEXT:  $BB5_1: # %entry
1442; MMR6-NEXT:    # =>This Inner Loop Header: Depth=1
1443; MMR6-NEXT:    ll $2, 0($6)
1444; MMR6-NEXT:    slt $5, $2, $7
1445; MMR6-NEXT:    selnez $3, $2, $5
1446; MMR6-NEXT:    seleqz $5, $7, $5
1447; MMR6-NEXT:    or $3, $3, $5
1448; MMR6-NEXT:    and $3, $3, $8
1449; MMR6-NEXT:    and $4, $2, $9
1450; MMR6-NEXT:    or $4, $4, $3
1451; MMR6-NEXT:    sc $4, 0($6)
1452; MMR6-NEXT:    beqc $4, $zero, $BB5_1
1453; MMR6-NEXT:  # %bb.2: # %entry
1454; MMR6-NEXT:    and $1, $2, $8
1455; MMR6-NEXT:    srlv $1, $1, $10
1456; MMR6-NEXT:    seh $1, $1
1457; MMR6-NEXT:  # %bb.3: # %entry
1458; MMR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
1459; MMR6-NEXT:  # %bb.4: # %entry
1460; MMR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
1461; MMR6-NEXT:    sync
1462; MMR6-NEXT:    addiu $sp, $sp, 8
1463; MMR6-NEXT:    jrc $ra
1464;
1465; MIPSEL-LABEL: test_min_16:
1466; MIPSEL:       # %bb.0: # %entry
1467; MIPSEL-NEXT:    addiu $sp, $sp, -8
1468; MIPSEL-NEXT:    .cfi_def_cfa_offset 8
1469; MIPSEL-NEXT:    # kill: def $at killed $a1
1470; MIPSEL-NEXT:    sync
1471; MIPSEL-NEXT:    addiu $1, $zero, -4
1472; MIPSEL-NEXT:    and $6, $4, $1
1473; MIPSEL-NEXT:    andi $1, $4, 3
1474; MIPSEL-NEXT:    sll $10, $1, 3
1475; MIPSEL-NEXT:    ori $1, $zero, 65535
1476; MIPSEL-NEXT:    sllv $8, $1, $10
1477; MIPSEL-NEXT:    nor $9, $zero, $8
1478; MIPSEL-NEXT:    sllv $7, $5, $10
1479; MIPSEL-NEXT:  $BB5_1: # %entry
1480; MIPSEL-NEXT:    # =>This Inner Loop Header: Depth=1
1481; MIPSEL-NEXT:    ll $2, 0($6)
1482; MIPSEL-NEXT:    and $2, $2, $8
1483; MIPSEL-NEXT:    and $7, $7, $8
1484; MIPSEL-NEXT:    slt $5, $2, $7
1485; MIPSEL-NEXT:    move $3, $2
1486; MIPSEL-NEXT:    movz $3, $7, $5
1487; MIPSEL-NEXT:    and $3, $3, $8
1488; MIPSEL-NEXT:    and $4, $2, $9
1489; MIPSEL-NEXT:    or $4, $4, $3
1490; MIPSEL-NEXT:    sc $4, 0($6)
1491; MIPSEL-NEXT:    beqz $4, $BB5_1
1492; MIPSEL-NEXT:    nop
1493; MIPSEL-NEXT:  # %bb.2: # %entry
1494; MIPSEL-NEXT:    and $1, $2, $8
1495; MIPSEL-NEXT:    srlv $1, $1, $10
1496; MIPSEL-NEXT:    seh $1, $1
1497; MIPSEL-NEXT:  # %bb.3: # %entry
1498; MIPSEL-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
1499; MIPSEL-NEXT:  # %bb.4: # %entry
1500; MIPSEL-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
1501; MIPSEL-NEXT:    sync
1502; MIPSEL-NEXT:    addiu $sp, $sp, 8
1503; MIPSEL-NEXT:    jr $ra
1504; MIPSEL-NEXT:    nop
1505;
1506; MIPSELR6-LABEL: test_min_16:
1507; MIPSELR6:       # %bb.0: # %entry
1508; MIPSELR6-NEXT:    addiu $sp, $sp, -8
1509; MIPSELR6-NEXT:    .cfi_def_cfa_offset 8
1510; MIPSELR6-NEXT:    # kill: def $at killed $a1
1511; MIPSELR6-NEXT:    sync
1512; MIPSELR6-NEXT:    addiu $1, $zero, -4
1513; MIPSELR6-NEXT:    and $6, $4, $1
1514; MIPSELR6-NEXT:    andi $1, $4, 3
1515; MIPSELR6-NEXT:    sll $10, $1, 3
1516; MIPSELR6-NEXT:    ori $1, $zero, 65535
1517; MIPSELR6-NEXT:    sllv $8, $1, $10
1518; MIPSELR6-NEXT:    nor $9, $zero, $8
1519; MIPSELR6-NEXT:    sllv $7, $5, $10
1520; MIPSELR6-NEXT:  $BB5_1: # %entry
1521; MIPSELR6-NEXT:    # =>This Inner Loop Header: Depth=1
1522; MIPSELR6-NEXT:    ll $2, 0($6)
1523; MIPSELR6-NEXT:    and $2, $2, $8
1524; MIPSELR6-NEXT:    and $7, $7, $8
1525; MIPSELR6-NEXT:    slt $5, $2, $7
1526; MIPSELR6-NEXT:    selnez $3, $2, $5
1527; MIPSELR6-NEXT:    seleqz $5, $7, $5
1528; MIPSELR6-NEXT:    or $3, $3, $5
1529; MIPSELR6-NEXT:    and $3, $3, $8
1530; MIPSELR6-NEXT:    and $4, $2, $9
1531; MIPSELR6-NEXT:    or $4, $4, $3
1532; MIPSELR6-NEXT:    sc $4, 0($6)
1533; MIPSELR6-NEXT:    beqzc $4, $BB5_1
1534; MIPSELR6-NEXT:  # %bb.2: # %entry
1535; MIPSELR6-NEXT:    and $1, $2, $8
1536; MIPSELR6-NEXT:    srlv $1, $1, $10
1537; MIPSELR6-NEXT:    seh $1, $1
1538; MIPSELR6-NEXT:  # %bb.3: # %entry
1539; MIPSELR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
1540; MIPSELR6-NEXT:  # %bb.4: # %entry
1541; MIPSELR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
1542; MIPSELR6-NEXT:    sync
1543; MIPSELR6-NEXT:    addiu $sp, $sp, 8
1544; MIPSELR6-NEXT:    jrc $ra
1545;
1546; MMEL-LABEL: test_min_16:
1547; MMEL:       # %bb.0: # %entry
1548; MMEL-NEXT:    addiu $sp, $sp, -8
1549; MMEL-NEXT:    .cfi_def_cfa_offset 8
1550; MMEL-NEXT:    # kill: def $at killed $a1
1551; MMEL-NEXT:    sync
1552; MMEL-NEXT:    addiu $1, $zero, -4
1553; MMEL-NEXT:    and $6, $4, $1
1554; MMEL-NEXT:    andi $1, $4, 3
1555; MMEL-NEXT:    sll $10, $1, 3
1556; MMEL-NEXT:    ori $1, $zero, 65535
1557; MMEL-NEXT:    sllv $8, $1, $10
1558; MMEL-NEXT:    nor $9, $zero, $8
1559; MMEL-NEXT:    sllv $7, $5, $10
1560; MMEL-NEXT:  $BB5_1: # %entry
1561; MMEL-NEXT:    # =>This Inner Loop Header: Depth=1
1562; MMEL-NEXT:    ll $2, 0($6)
1563; MMEL-NEXT:    and $2, $2, $8
1564; MMEL-NEXT:    and $7, $7, $8
1565; MMEL-NEXT:    slt $5, $2, $7
1566; MMEL-NEXT:    or $3, $2, $zero
1567; MMEL-NEXT:    movz $3, $7, $5
1568; MMEL-NEXT:    and $3, $3, $8
1569; MMEL-NEXT:    and $4, $2, $9
1570; MMEL-NEXT:    or $4, $4, $3
1571; MMEL-NEXT:    sc $4, 0($6)
1572; MMEL-NEXT:    beqzc $4, $BB5_1
1573; MMEL-NEXT:  # %bb.2: # %entry
1574; MMEL-NEXT:    and $1, $2, $8
1575; MMEL-NEXT:    srlv $1, $1, $10
1576; MMEL-NEXT:    seh $1, $1
1577; MMEL-NEXT:  # %bb.3: # %entry
1578; MMEL-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
1579; MMEL-NEXT:  # %bb.4: # %entry
1580; MMEL-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
1581; MMEL-NEXT:    sync
1582; MMEL-NEXT:    addiusp 8
1583; MMEL-NEXT:    jrc $ra
1584;
1585; MMELR6-LABEL: test_min_16:
1586; MMELR6:       # %bb.0: # %entry
1587; MMELR6-NEXT:    addiu $sp, $sp, -8
1588; MMELR6-NEXT:    .cfi_def_cfa_offset 8
1589; MMELR6-NEXT:    # kill: def $at killed $a1
1590; MMELR6-NEXT:    sync
1591; MMELR6-NEXT:    addiu $1, $zero, -4
1592; MMELR6-NEXT:    and $6, $4, $1
1593; MMELR6-NEXT:    andi $1, $4, 3
1594; MMELR6-NEXT:    sll $10, $1, 3
1595; MMELR6-NEXT:    ori $1, $zero, 65535
1596; MMELR6-NEXT:    sllv $8, $1, $10
1597; MMELR6-NEXT:    nor $9, $zero, $8
1598; MMELR6-NEXT:    sllv $7, $5, $10
1599; MMELR6-NEXT:  $BB5_1: # %entry
1600; MMELR6-NEXT:    # =>This Inner Loop Header: Depth=1
1601; MMELR6-NEXT:    ll $2, 0($6)
1602; MMELR6-NEXT:    and $2, $2, $8
1603; MMELR6-NEXT:    and $7, $7, $8
1604; MMELR6-NEXT:    slt $5, $2, $7
1605; MMELR6-NEXT:    selnez $3, $2, $5
1606; MMELR6-NEXT:    seleqz $5, $7, $5
1607; MMELR6-NEXT:    or $3, $3, $5
1608; MMELR6-NEXT:    and $3, $3, $8
1609; MMELR6-NEXT:    and $4, $2, $9
1610; MMELR6-NEXT:    or $4, $4, $3
1611; MMELR6-NEXT:    sc $4, 0($6)
1612; MMELR6-NEXT:    beqc $4, $zero, $BB5_1
1613; MMELR6-NEXT:  # %bb.2: # %entry
1614; MMELR6-NEXT:    and $1, $2, $8
1615; MMELR6-NEXT:    srlv $1, $1, $10
1616; MMELR6-NEXT:    seh $1, $1
1617; MMELR6-NEXT:  # %bb.3: # %entry
1618; MMELR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
1619; MMELR6-NEXT:  # %bb.4: # %entry
1620; MMELR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
1621; MMELR6-NEXT:    sync
1622; MMELR6-NEXT:    addiu $sp, $sp, 8
1623; MMELR6-NEXT:    jrc $ra
1624;
1625; MIPS64-LABEL: test_min_16:
1626; MIPS64:       # %bb.0: # %entry
1627; MIPS64-NEXT:    daddiu $sp, $sp, -16
1628; MIPS64-NEXT:    .cfi_def_cfa_offset 16
1629; MIPS64-NEXT:    move $1, $5
1630; MIPS64-NEXT:    sync
1631; MIPS64-NEXT:    daddiu $2, $zero, -4
1632; MIPS64-NEXT:    and $6, $4, $2
1633; MIPS64-NEXT:    andi $2, $4, 3
1634; MIPS64-NEXT:    xori $2, $2, 2
1635; MIPS64-NEXT:    sll $10, $2, 3
1636; MIPS64-NEXT:    ori $2, $zero, 65535
1637; MIPS64-NEXT:    sllv $8, $2, $10
1638; MIPS64-NEXT:    nor $9, $zero, $8
1639; MIPS64-NEXT:    sllv $7, $1, $10
1640; MIPS64-NEXT:  .LBB5_1: # %entry
1641; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
1642; MIPS64-NEXT:    ll $2, 0($6)
1643; MIPS64-NEXT:    slt $5, $2, $7
1644; MIPS64-NEXT:    move $3, $2
1645; MIPS64-NEXT:    movz $3, $7, $5
1646; MIPS64-NEXT:    and $3, $3, $8
1647; MIPS64-NEXT:    and $4, $2, $9
1648; MIPS64-NEXT:    or $4, $4, $3
1649; MIPS64-NEXT:    sc $4, 0($6)
1650; MIPS64-NEXT:    beqz $4, .LBB5_1
1651; MIPS64-NEXT:    nop
1652; MIPS64-NEXT:  # %bb.2: # %entry
1653; MIPS64-NEXT:    and $1, $2, $8
1654; MIPS64-NEXT:    srlv $1, $1, $10
1655; MIPS64-NEXT:    seh $1, $1
1656; MIPS64-NEXT:  # %bb.3: # %entry
1657; MIPS64-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
1658; MIPS64-NEXT:  # %bb.4: # %entry
1659; MIPS64-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
1660; MIPS64-NEXT:    sync
1661; MIPS64-NEXT:    daddiu $sp, $sp, 16
1662; MIPS64-NEXT:    jr $ra
1663; MIPS64-NEXT:    nop
1664;
1665; MIPS64R6-LABEL: test_min_16:
1666; MIPS64R6:       # %bb.0: # %entry
1667; MIPS64R6-NEXT:    daddiu $sp, $sp, -16
1668; MIPS64R6-NEXT:    .cfi_def_cfa_offset 16
1669; MIPS64R6-NEXT:    move $1, $5
1670; MIPS64R6-NEXT:    sync
1671; MIPS64R6-NEXT:    daddiu $2, $zero, -4
1672; MIPS64R6-NEXT:    and $6, $4, $2
1673; MIPS64R6-NEXT:    andi $2, $4, 3
1674; MIPS64R6-NEXT:    xori $2, $2, 2
1675; MIPS64R6-NEXT:    sll $10, $2, 3
1676; MIPS64R6-NEXT:    ori $2, $zero, 65535
1677; MIPS64R6-NEXT:    sllv $8, $2, $10
1678; MIPS64R6-NEXT:    nor $9, $zero, $8
1679; MIPS64R6-NEXT:    sllv $7, $1, $10
1680; MIPS64R6-NEXT:  .LBB5_1: # %entry
1681; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
1682; MIPS64R6-NEXT:    ll $2, 0($6)
1683; MIPS64R6-NEXT:    slt $5, $2, $7
1684; MIPS64R6-NEXT:    selnez $3, $2, $5
1685; MIPS64R6-NEXT:    seleqz $5, $7, $5
1686; MIPS64R6-NEXT:    or $3, $3, $5
1687; MIPS64R6-NEXT:    and $3, $3, $8
1688; MIPS64R6-NEXT:    and $4, $2, $9
1689; MIPS64R6-NEXT:    or $4, $4, $3
1690; MIPS64R6-NEXT:    sc $4, 0($6)
1691; MIPS64R6-NEXT:    beqzc $4, .LBB5_1
1692; MIPS64R6-NEXT:  # %bb.2: # %entry
1693; MIPS64R6-NEXT:    and $1, $2, $8
1694; MIPS64R6-NEXT:    srlv $1, $1, $10
1695; MIPS64R6-NEXT:    seh $1, $1
1696; MIPS64R6-NEXT:  # %bb.3: # %entry
1697; MIPS64R6-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
1698; MIPS64R6-NEXT:  # %bb.4: # %entry
1699; MIPS64R6-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
1700; MIPS64R6-NEXT:    sync
1701; MIPS64R6-NEXT:    daddiu $sp, $sp, 16
1702; MIPS64R6-NEXT:    jrc $ra
1703;
1704; MIPS64EL-LABEL: test_min_16:
1705; MIPS64EL:       # %bb.0: # %entry
1706; MIPS64EL-NEXT:    daddiu $sp, $sp, -16
1707; MIPS64EL-NEXT:    .cfi_def_cfa_offset 16
1708; MIPS64EL-NEXT:    move $1, $5
1709; MIPS64EL-NEXT:    sync
1710; MIPS64EL-NEXT:    daddiu $2, $zero, -4
1711; MIPS64EL-NEXT:    and $6, $4, $2
1712; MIPS64EL-NEXT:    andi $2, $4, 3
1713; MIPS64EL-NEXT:    sll $10, $2, 3
1714; MIPS64EL-NEXT:    ori $2, $zero, 65535
1715; MIPS64EL-NEXT:    sllv $8, $2, $10
1716; MIPS64EL-NEXT:    nor $9, $zero, $8
1717; MIPS64EL-NEXT:    sllv $7, $1, $10
1718; MIPS64EL-NEXT:  .LBB5_1: # %entry
1719; MIPS64EL-NEXT:    # =>This Inner Loop Header: Depth=1
1720; MIPS64EL-NEXT:    ll $2, 0($6)
1721; MIPS64EL-NEXT:    and $2, $2, $8
1722; MIPS64EL-NEXT:    and $7, $7, $8
1723; MIPS64EL-NEXT:    slt $5, $2, $7
1724; MIPS64EL-NEXT:    move $3, $2
1725; MIPS64EL-NEXT:    movz $3, $7, $5
1726; MIPS64EL-NEXT:    and $3, $3, $8
1727; MIPS64EL-NEXT:    and $4, $2, $9
1728; MIPS64EL-NEXT:    or $4, $4, $3
1729; MIPS64EL-NEXT:    sc $4, 0($6)
1730; MIPS64EL-NEXT:    beqz $4, .LBB5_1
1731; MIPS64EL-NEXT:    nop
1732; MIPS64EL-NEXT:  # %bb.2: # %entry
1733; MIPS64EL-NEXT:    and $1, $2, $8
1734; MIPS64EL-NEXT:    srlv $1, $1, $10
1735; MIPS64EL-NEXT:    seh $1, $1
1736; MIPS64EL-NEXT:  # %bb.3: # %entry
1737; MIPS64EL-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
1738; MIPS64EL-NEXT:  # %bb.4: # %entry
1739; MIPS64EL-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
1740; MIPS64EL-NEXT:    sync
1741; MIPS64EL-NEXT:    daddiu $sp, $sp, 16
1742; MIPS64EL-NEXT:    jr $ra
1743; MIPS64EL-NEXT:    nop
1744;
1745; MIPS64ELR6-LABEL: test_min_16:
1746; MIPS64ELR6:       # %bb.0: # %entry
1747; MIPS64ELR6-NEXT:    daddiu $sp, $sp, -16
1748; MIPS64ELR6-NEXT:    .cfi_def_cfa_offset 16
1749; MIPS64ELR6-NEXT:    move $1, $5
1750; MIPS64ELR6-NEXT:    sync
1751; MIPS64ELR6-NEXT:    daddiu $2, $zero, -4
1752; MIPS64ELR6-NEXT:    and $6, $4, $2
1753; MIPS64ELR6-NEXT:    andi $2, $4, 3
1754; MIPS64ELR6-NEXT:    sll $10, $2, 3
1755; MIPS64ELR6-NEXT:    ori $2, $zero, 65535
1756; MIPS64ELR6-NEXT:    sllv $8, $2, $10
1757; MIPS64ELR6-NEXT:    nor $9, $zero, $8
1758; MIPS64ELR6-NEXT:    sllv $7, $1, $10
1759; MIPS64ELR6-NEXT:  .LBB5_1: # %entry
1760; MIPS64ELR6-NEXT:    # =>This Inner Loop Header: Depth=1
1761; MIPS64ELR6-NEXT:    ll $2, 0($6)
1762; MIPS64ELR6-NEXT:    and $2, $2, $8
1763; MIPS64ELR6-NEXT:    and $7, $7, $8
1764; MIPS64ELR6-NEXT:    slt $5, $2, $7
1765; MIPS64ELR6-NEXT:    selnez $3, $2, $5
1766; MIPS64ELR6-NEXT:    seleqz $5, $7, $5
1767; MIPS64ELR6-NEXT:    or $3, $3, $5
1768; MIPS64ELR6-NEXT:    and $3, $3, $8
1769; MIPS64ELR6-NEXT:    and $4, $2, $9
1770; MIPS64ELR6-NEXT:    or $4, $4, $3
1771; MIPS64ELR6-NEXT:    sc $4, 0($6)
1772; MIPS64ELR6-NEXT:    beqzc $4, .LBB5_1
1773; MIPS64ELR6-NEXT:  # %bb.2: # %entry
1774; MIPS64ELR6-NEXT:    and $1, $2, $8
1775; MIPS64ELR6-NEXT:    srlv $1, $1, $10
1776; MIPS64ELR6-NEXT:    seh $1, $1
1777; MIPS64ELR6-NEXT:  # %bb.3: # %entry
1778; MIPS64ELR6-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
1779; MIPS64ELR6-NEXT:  # %bb.4: # %entry
1780; MIPS64ELR6-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
1781; MIPS64ELR6-NEXT:    sync
1782; MIPS64ELR6-NEXT:    daddiu $sp, $sp, 16
1783; MIPS64ELR6-NEXT:    jrc $ra
1784entry:
1785  %0 = atomicrmw min i16* %ptr, i16 %val seq_cst
1786  ret i16 %0
1787}
1788
1789define i16 @test_umax_16(i16* nocapture %ptr, i16 signext %val) {
1790; MIPS-LABEL: test_umax_16:
1791; MIPS:       # %bb.0: # %entry
1792; MIPS-NEXT:    addiu $sp, $sp, -8
1793; MIPS-NEXT:    .cfi_def_cfa_offset 8
1794; MIPS-NEXT:    # kill: def $at killed $a1
1795; MIPS-NEXT:    sync
1796; MIPS-NEXT:    addiu $1, $zero, -4
1797; MIPS-NEXT:    and $6, $4, $1
1798; MIPS-NEXT:    andi $1, $4, 3
1799; MIPS-NEXT:    xori $1, $1, 2
1800; MIPS-NEXT:    sll $10, $1, 3
1801; MIPS-NEXT:    ori $1, $zero, 65535
1802; MIPS-NEXT:    sllv $8, $1, $10
1803; MIPS-NEXT:    nor $9, $zero, $8
1804; MIPS-NEXT:    sllv $7, $5, $10
1805; MIPS-NEXT:  $BB6_1: # %entry
1806; MIPS-NEXT:    # =>This Inner Loop Header: Depth=1
1807; MIPS-NEXT:    ll $2, 0($6)
1808; MIPS-NEXT:    sltu $5, $2, $7
1809; MIPS-NEXT:    move $3, $2
1810; MIPS-NEXT:    movn $3, $7, $5
1811; MIPS-NEXT:    and $3, $3, $8
1812; MIPS-NEXT:    and $4, $2, $9
1813; MIPS-NEXT:    or $4, $4, $3
1814; MIPS-NEXT:    sc $4, 0($6)
1815; MIPS-NEXT:    beqz $4, $BB6_1
1816; MIPS-NEXT:    nop
1817; MIPS-NEXT:  # %bb.2: # %entry
1818; MIPS-NEXT:    and $1, $2, $8
1819; MIPS-NEXT:    srlv $1, $1, $10
1820; MIPS-NEXT:    seh $1, $1
1821; MIPS-NEXT:  # %bb.3: # %entry
1822; MIPS-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
1823; MIPS-NEXT:  # %bb.4: # %entry
1824; MIPS-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
1825; MIPS-NEXT:    sync
1826; MIPS-NEXT:    addiu $sp, $sp, 8
1827; MIPS-NEXT:    jr $ra
1828; MIPS-NEXT:    nop
1829;
1830; MIPSR6-LABEL: test_umax_16:
1831; MIPSR6:       # %bb.0: # %entry
1832; MIPSR6-NEXT:    addiu $sp, $sp, -8
1833; MIPSR6-NEXT:    .cfi_def_cfa_offset 8
1834; MIPSR6-NEXT:    # kill: def $at killed $a1
1835; MIPSR6-NEXT:    sync
1836; MIPSR6-NEXT:    addiu $1, $zero, -4
1837; MIPSR6-NEXT:    and $6, $4, $1
1838; MIPSR6-NEXT:    andi $1, $4, 3
1839; MIPSR6-NEXT:    xori $1, $1, 2
1840; MIPSR6-NEXT:    sll $10, $1, 3
1841; MIPSR6-NEXT:    ori $1, $zero, 65535
1842; MIPSR6-NEXT:    sllv $8, $1, $10
1843; MIPSR6-NEXT:    nor $9, $zero, $8
1844; MIPSR6-NEXT:    sllv $7, $5, $10
1845; MIPSR6-NEXT:  $BB6_1: # %entry
1846; MIPSR6-NEXT:    # =>This Inner Loop Header: Depth=1
1847; MIPSR6-NEXT:    ll $2, 0($6)
1848; MIPSR6-NEXT:    sltu $5, $2, $7
1849; MIPSR6-NEXT:    seleqz $3, $2, $5
1850; MIPSR6-NEXT:    selnez $5, $7, $5
1851; MIPSR6-NEXT:    or $3, $3, $5
1852; MIPSR6-NEXT:    and $3, $3, $8
1853; MIPSR6-NEXT:    and $4, $2, $9
1854; MIPSR6-NEXT:    or $4, $4, $3
1855; MIPSR6-NEXT:    sc $4, 0($6)
1856; MIPSR6-NEXT:    beqzc $4, $BB6_1
1857; MIPSR6-NEXT:  # %bb.2: # %entry
1858; MIPSR6-NEXT:    and $1, $2, $8
1859; MIPSR6-NEXT:    srlv $1, $1, $10
1860; MIPSR6-NEXT:    seh $1, $1
1861; MIPSR6-NEXT:  # %bb.3: # %entry
1862; MIPSR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
1863; MIPSR6-NEXT:  # %bb.4: # %entry
1864; MIPSR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
1865; MIPSR6-NEXT:    sync
1866; MIPSR6-NEXT:    addiu $sp, $sp, 8
1867; MIPSR6-NEXT:    jrc $ra
1868;
1869; MM-LABEL: test_umax_16:
1870; MM:       # %bb.0: # %entry
1871; MM-NEXT:    addiu $sp, $sp, -8
1872; MM-NEXT:    .cfi_def_cfa_offset 8
1873; MM-NEXT:    # kill: def $at killed $a1
1874; MM-NEXT:    sync
1875; MM-NEXT:    addiu $1, $zero, -4
1876; MM-NEXT:    and $6, $4, $1
1877; MM-NEXT:    andi $1, $4, 3
1878; MM-NEXT:    xori $1, $1, 2
1879; MM-NEXT:    sll $10, $1, 3
1880; MM-NEXT:    ori $1, $zero, 65535
1881; MM-NEXT:    sllv $8, $1, $10
1882; MM-NEXT:    nor $9, $zero, $8
1883; MM-NEXT:    sllv $7, $5, $10
1884; MM-NEXT:  $BB6_1: # %entry
1885; MM-NEXT:    # =>This Inner Loop Header: Depth=1
1886; MM-NEXT:    ll $2, 0($6)
1887; MM-NEXT:    sltu $5, $2, $7
1888; MM-NEXT:    or $3, $2, $zero
1889; MM-NEXT:    movn $3, $7, $5
1890; MM-NEXT:    and $3, $3, $8
1891; MM-NEXT:    and $4, $2, $9
1892; MM-NEXT:    or $4, $4, $3
1893; MM-NEXT:    sc $4, 0($6)
1894; MM-NEXT:    beqzc $4, $BB6_1
1895; MM-NEXT:  # %bb.2: # %entry
1896; MM-NEXT:    and $1, $2, $8
1897; MM-NEXT:    srlv $1, $1, $10
1898; MM-NEXT:    seh $1, $1
1899; MM-NEXT:  # %bb.3: # %entry
1900; MM-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
1901; MM-NEXT:  # %bb.4: # %entry
1902; MM-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
1903; MM-NEXT:    sync
1904; MM-NEXT:    addiusp 8
1905; MM-NEXT:    jrc $ra
1906;
1907; MMR6-LABEL: test_umax_16:
1908; MMR6:       # %bb.0: # %entry
1909; MMR6-NEXT:    addiu $sp, $sp, -8
1910; MMR6-NEXT:    .cfi_def_cfa_offset 8
1911; MMR6-NEXT:    # kill: def $at killed $a1
1912; MMR6-NEXT:    sync
1913; MMR6-NEXT:    addiu $1, $zero, -4
1914; MMR6-NEXT:    and $6, $4, $1
1915; MMR6-NEXT:    andi $1, $4, 3
1916; MMR6-NEXT:    xori $1, $1, 2
1917; MMR6-NEXT:    sll $10, $1, 3
1918; MMR6-NEXT:    ori $1, $zero, 65535
1919; MMR6-NEXT:    sllv $8, $1, $10
1920; MMR6-NEXT:    nor $9, $zero, $8
1921; MMR6-NEXT:    sllv $7, $5, $10
1922; MMR6-NEXT:  $BB6_1: # %entry
1923; MMR6-NEXT:    # =>This Inner Loop Header: Depth=1
1924; MMR6-NEXT:    ll $2, 0($6)
1925; MMR6-NEXT:    sltu $5, $2, $7
1926; MMR6-NEXT:    seleqz $3, $2, $5
1927; MMR6-NEXT:    selnez $5, $7, $5
1928; MMR6-NEXT:    or $3, $3, $5
1929; MMR6-NEXT:    and $3, $3, $8
1930; MMR6-NEXT:    and $4, $2, $9
1931; MMR6-NEXT:    or $4, $4, $3
1932; MMR6-NEXT:    sc $4, 0($6)
1933; MMR6-NEXT:    beqc $4, $zero, $BB6_1
1934; MMR6-NEXT:  # %bb.2: # %entry
1935; MMR6-NEXT:    and $1, $2, $8
1936; MMR6-NEXT:    srlv $1, $1, $10
1937; MMR6-NEXT:    seh $1, $1
1938; MMR6-NEXT:  # %bb.3: # %entry
1939; MMR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
1940; MMR6-NEXT:  # %bb.4: # %entry
1941; MMR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
1942; MMR6-NEXT:    sync
1943; MMR6-NEXT:    addiu $sp, $sp, 8
1944; MMR6-NEXT:    jrc $ra
1945;
1946; MIPSEL-LABEL: test_umax_16:
1947; MIPSEL:       # %bb.0: # %entry
1948; MIPSEL-NEXT:    addiu $sp, $sp, -8
1949; MIPSEL-NEXT:    .cfi_def_cfa_offset 8
1950; MIPSEL-NEXT:    # kill: def $at killed $a1
1951; MIPSEL-NEXT:    sync
1952; MIPSEL-NEXT:    addiu $1, $zero, -4
1953; MIPSEL-NEXT:    and $6, $4, $1
1954; MIPSEL-NEXT:    andi $1, $4, 3
1955; MIPSEL-NEXT:    sll $10, $1, 3
1956; MIPSEL-NEXT:    ori $1, $zero, 65535
1957; MIPSEL-NEXT:    sllv $8, $1, $10
1958; MIPSEL-NEXT:    nor $9, $zero, $8
1959; MIPSEL-NEXT:    sllv $7, $5, $10
1960; MIPSEL-NEXT:  $BB6_1: # %entry
1961; MIPSEL-NEXT:    # =>This Inner Loop Header: Depth=1
1962; MIPSEL-NEXT:    ll $2, 0($6)
1963; MIPSEL-NEXT:    and $2, $2, $8
1964; MIPSEL-NEXT:    and $7, $7, $8
1965; MIPSEL-NEXT:    sltu $5, $2, $7
1966; MIPSEL-NEXT:    move $3, $2
1967; MIPSEL-NEXT:    movn $3, $7, $5
1968; MIPSEL-NEXT:    and $3, $3, $8
1969; MIPSEL-NEXT:    and $4, $2, $9
1970; MIPSEL-NEXT:    or $4, $4, $3
1971; MIPSEL-NEXT:    sc $4, 0($6)
1972; MIPSEL-NEXT:    beqz $4, $BB6_1
1973; MIPSEL-NEXT:    nop
1974; MIPSEL-NEXT:  # %bb.2: # %entry
1975; MIPSEL-NEXT:    and $1, $2, $8
1976; MIPSEL-NEXT:    srlv $1, $1, $10
1977; MIPSEL-NEXT:    seh $1, $1
1978; MIPSEL-NEXT:  # %bb.3: # %entry
1979; MIPSEL-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
1980; MIPSEL-NEXT:  # %bb.4: # %entry
1981; MIPSEL-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
1982; MIPSEL-NEXT:    sync
1983; MIPSEL-NEXT:    addiu $sp, $sp, 8
1984; MIPSEL-NEXT:    jr $ra
1985; MIPSEL-NEXT:    nop
1986;
1987; MIPSELR6-LABEL: test_umax_16:
1988; MIPSELR6:       # %bb.0: # %entry
1989; MIPSELR6-NEXT:    addiu $sp, $sp, -8
1990; MIPSELR6-NEXT:    .cfi_def_cfa_offset 8
1991; MIPSELR6-NEXT:    # kill: def $at killed $a1
1992; MIPSELR6-NEXT:    sync
1993; MIPSELR6-NEXT:    addiu $1, $zero, -4
1994; MIPSELR6-NEXT:    and $6, $4, $1
1995; MIPSELR6-NEXT:    andi $1, $4, 3
1996; MIPSELR6-NEXT:    sll $10, $1, 3
1997; MIPSELR6-NEXT:    ori $1, $zero, 65535
1998; MIPSELR6-NEXT:    sllv $8, $1, $10
1999; MIPSELR6-NEXT:    nor $9, $zero, $8
2000; MIPSELR6-NEXT:    sllv $7, $5, $10
2001; MIPSELR6-NEXT:  $BB6_1: # %entry
2002; MIPSELR6-NEXT:    # =>This Inner Loop Header: Depth=1
2003; MIPSELR6-NEXT:    ll $2, 0($6)
2004; MIPSELR6-NEXT:    and $2, $2, $8
2005; MIPSELR6-NEXT:    and $7, $7, $8
2006; MIPSELR6-NEXT:    sltu $5, $2, $7
2007; MIPSELR6-NEXT:    seleqz $3, $2, $5
2008; MIPSELR6-NEXT:    selnez $5, $7, $5
2009; MIPSELR6-NEXT:    or $3, $3, $5
2010; MIPSELR6-NEXT:    and $3, $3, $8
2011; MIPSELR6-NEXT:    and $4, $2, $9
2012; MIPSELR6-NEXT:    or $4, $4, $3
2013; MIPSELR6-NEXT:    sc $4, 0($6)
2014; MIPSELR6-NEXT:    beqzc $4, $BB6_1
2015; MIPSELR6-NEXT:  # %bb.2: # %entry
2016; MIPSELR6-NEXT:    and $1, $2, $8
2017; MIPSELR6-NEXT:    srlv $1, $1, $10
2018; MIPSELR6-NEXT:    seh $1, $1
2019; MIPSELR6-NEXT:  # %bb.3: # %entry
2020; MIPSELR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2021; MIPSELR6-NEXT:  # %bb.4: # %entry
2022; MIPSELR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
2023; MIPSELR6-NEXT:    sync
2024; MIPSELR6-NEXT:    addiu $sp, $sp, 8
2025; MIPSELR6-NEXT:    jrc $ra
2026;
2027; MMEL-LABEL: test_umax_16:
2028; MMEL:       # %bb.0: # %entry
2029; MMEL-NEXT:    addiu $sp, $sp, -8
2030; MMEL-NEXT:    .cfi_def_cfa_offset 8
2031; MMEL-NEXT:    # kill: def $at killed $a1
2032; MMEL-NEXT:    sync
2033; MMEL-NEXT:    addiu $1, $zero, -4
2034; MMEL-NEXT:    and $6, $4, $1
2035; MMEL-NEXT:    andi $1, $4, 3
2036; MMEL-NEXT:    sll $10, $1, 3
2037; MMEL-NEXT:    ori $1, $zero, 65535
2038; MMEL-NEXT:    sllv $8, $1, $10
2039; MMEL-NEXT:    nor $9, $zero, $8
2040; MMEL-NEXT:    sllv $7, $5, $10
2041; MMEL-NEXT:  $BB6_1: # %entry
2042; MMEL-NEXT:    # =>This Inner Loop Header: Depth=1
2043; MMEL-NEXT:    ll $2, 0($6)
2044; MMEL-NEXT:    and $2, $2, $8
2045; MMEL-NEXT:    and $7, $7, $8
2046; MMEL-NEXT:    sltu $5, $2, $7
2047; MMEL-NEXT:    or $3, $2, $zero
2048; MMEL-NEXT:    movn $3, $7, $5
2049; MMEL-NEXT:    and $3, $3, $8
2050; MMEL-NEXT:    and $4, $2, $9
2051; MMEL-NEXT:    or $4, $4, $3
2052; MMEL-NEXT:    sc $4, 0($6)
2053; MMEL-NEXT:    beqzc $4, $BB6_1
2054; MMEL-NEXT:  # %bb.2: # %entry
2055; MMEL-NEXT:    and $1, $2, $8
2056; MMEL-NEXT:    srlv $1, $1, $10
2057; MMEL-NEXT:    seh $1, $1
2058; MMEL-NEXT:  # %bb.3: # %entry
2059; MMEL-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2060; MMEL-NEXT:  # %bb.4: # %entry
2061; MMEL-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
2062; MMEL-NEXT:    sync
2063; MMEL-NEXT:    addiusp 8
2064; MMEL-NEXT:    jrc $ra
2065;
2066; MMELR6-LABEL: test_umax_16:
2067; MMELR6:       # %bb.0: # %entry
2068; MMELR6-NEXT:    addiu $sp, $sp, -8
2069; MMELR6-NEXT:    .cfi_def_cfa_offset 8
2070; MMELR6-NEXT:    # kill: def $at killed $a1
2071; MMELR6-NEXT:    sync
2072; MMELR6-NEXT:    addiu $1, $zero, -4
2073; MMELR6-NEXT:    and $6, $4, $1
2074; MMELR6-NEXT:    andi $1, $4, 3
2075; MMELR6-NEXT:    sll $10, $1, 3
2076; MMELR6-NEXT:    ori $1, $zero, 65535
2077; MMELR6-NEXT:    sllv $8, $1, $10
2078; MMELR6-NEXT:    nor $9, $zero, $8
2079; MMELR6-NEXT:    sllv $7, $5, $10
2080; MMELR6-NEXT:  $BB6_1: # %entry
2081; MMELR6-NEXT:    # =>This Inner Loop Header: Depth=1
2082; MMELR6-NEXT:    ll $2, 0($6)
2083; MMELR6-NEXT:    and $2, $2, $8
2084; MMELR6-NEXT:    and $7, $7, $8
2085; MMELR6-NEXT:    sltu $5, $2, $7
2086; MMELR6-NEXT:    seleqz $3, $2, $5
2087; MMELR6-NEXT:    selnez $5, $7, $5
2088; MMELR6-NEXT:    or $3, $3, $5
2089; MMELR6-NEXT:    and $3, $3, $8
2090; MMELR6-NEXT:    and $4, $2, $9
2091; MMELR6-NEXT:    or $4, $4, $3
2092; MMELR6-NEXT:    sc $4, 0($6)
2093; MMELR6-NEXT:    beqc $4, $zero, $BB6_1
2094; MMELR6-NEXT:  # %bb.2: # %entry
2095; MMELR6-NEXT:    and $1, $2, $8
2096; MMELR6-NEXT:    srlv $1, $1, $10
2097; MMELR6-NEXT:    seh $1, $1
2098; MMELR6-NEXT:  # %bb.3: # %entry
2099; MMELR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2100; MMELR6-NEXT:  # %bb.4: # %entry
2101; MMELR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
2102; MMELR6-NEXT:    sync
2103; MMELR6-NEXT:    addiu $sp, $sp, 8
2104; MMELR6-NEXT:    jrc $ra
2105;
2106; MIPS64-LABEL: test_umax_16:
2107; MIPS64:       # %bb.0: # %entry
2108; MIPS64-NEXT:    daddiu $sp, $sp, -16
2109; MIPS64-NEXT:    .cfi_def_cfa_offset 16
2110; MIPS64-NEXT:    move $1, $5
2111; MIPS64-NEXT:    sync
2112; MIPS64-NEXT:    daddiu $2, $zero, -4
2113; MIPS64-NEXT:    and $6, $4, $2
2114; MIPS64-NEXT:    andi $2, $4, 3
2115; MIPS64-NEXT:    xori $2, $2, 2
2116; MIPS64-NEXT:    sll $10, $2, 3
2117; MIPS64-NEXT:    ori $2, $zero, 65535
2118; MIPS64-NEXT:    sllv $8, $2, $10
2119; MIPS64-NEXT:    nor $9, $zero, $8
2120; MIPS64-NEXT:    sllv $7, $1, $10
2121; MIPS64-NEXT:  .LBB6_1: # %entry
2122; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
2123; MIPS64-NEXT:    ll $2, 0($6)
2124; MIPS64-NEXT:    sltu $5, $2, $7
2125; MIPS64-NEXT:    move $3, $2
2126; MIPS64-NEXT:    movn $3, $7, $5
2127; MIPS64-NEXT:    and $3, $3, $8
2128; MIPS64-NEXT:    and $4, $2, $9
2129; MIPS64-NEXT:    or $4, $4, $3
2130; MIPS64-NEXT:    sc $4, 0($6)
2131; MIPS64-NEXT:    beqz $4, .LBB6_1
2132; MIPS64-NEXT:    nop
2133; MIPS64-NEXT:  # %bb.2: # %entry
2134; MIPS64-NEXT:    and $1, $2, $8
2135; MIPS64-NEXT:    srlv $1, $1, $10
2136; MIPS64-NEXT:    seh $1, $1
2137; MIPS64-NEXT:  # %bb.3: # %entry
2138; MIPS64-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
2139; MIPS64-NEXT:  # %bb.4: # %entry
2140; MIPS64-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
2141; MIPS64-NEXT:    sync
2142; MIPS64-NEXT:    daddiu $sp, $sp, 16
2143; MIPS64-NEXT:    jr $ra
2144; MIPS64-NEXT:    nop
2145;
2146; MIPS64R6-LABEL: test_umax_16:
2147; MIPS64R6:       # %bb.0: # %entry
2148; MIPS64R6-NEXT:    daddiu $sp, $sp, -16
2149; MIPS64R6-NEXT:    .cfi_def_cfa_offset 16
2150; MIPS64R6-NEXT:    move $1, $5
2151; MIPS64R6-NEXT:    sync
2152; MIPS64R6-NEXT:    daddiu $2, $zero, -4
2153; MIPS64R6-NEXT:    and $6, $4, $2
2154; MIPS64R6-NEXT:    andi $2, $4, 3
2155; MIPS64R6-NEXT:    xori $2, $2, 2
2156; MIPS64R6-NEXT:    sll $10, $2, 3
2157; MIPS64R6-NEXT:    ori $2, $zero, 65535
2158; MIPS64R6-NEXT:    sllv $8, $2, $10
2159; MIPS64R6-NEXT:    nor $9, $zero, $8
2160; MIPS64R6-NEXT:    sllv $7, $1, $10
2161; MIPS64R6-NEXT:  .LBB6_1: # %entry
2162; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
2163; MIPS64R6-NEXT:    ll $2, 0($6)
2164; MIPS64R6-NEXT:    sltu $5, $2, $7
2165; MIPS64R6-NEXT:    seleqz $3, $2, $5
2166; MIPS64R6-NEXT:    selnez $5, $7, $5
2167; MIPS64R6-NEXT:    or $3, $3, $5
2168; MIPS64R6-NEXT:    and $3, $3, $8
2169; MIPS64R6-NEXT:    and $4, $2, $9
2170; MIPS64R6-NEXT:    or $4, $4, $3
2171; MIPS64R6-NEXT:    sc $4, 0($6)
2172; MIPS64R6-NEXT:    beqzc $4, .LBB6_1
2173; MIPS64R6-NEXT:  # %bb.2: # %entry
2174; MIPS64R6-NEXT:    and $1, $2, $8
2175; MIPS64R6-NEXT:    srlv $1, $1, $10
2176; MIPS64R6-NEXT:    seh $1, $1
2177; MIPS64R6-NEXT:  # %bb.3: # %entry
2178; MIPS64R6-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
2179; MIPS64R6-NEXT:  # %bb.4: # %entry
2180; MIPS64R6-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
2181; MIPS64R6-NEXT:    sync
2182; MIPS64R6-NEXT:    daddiu $sp, $sp, 16
2183; MIPS64R6-NEXT:    jrc $ra
2184;
2185; MIPS64EL-LABEL: test_umax_16:
2186; MIPS64EL:       # %bb.0: # %entry
2187; MIPS64EL-NEXT:    daddiu $sp, $sp, -16
2188; MIPS64EL-NEXT:    .cfi_def_cfa_offset 16
2189; MIPS64EL-NEXT:    move $1, $5
2190; MIPS64EL-NEXT:    sync
2191; MIPS64EL-NEXT:    daddiu $2, $zero, -4
2192; MIPS64EL-NEXT:    and $6, $4, $2
2193; MIPS64EL-NEXT:    andi $2, $4, 3
2194; MIPS64EL-NEXT:    sll $10, $2, 3
2195; MIPS64EL-NEXT:    ori $2, $zero, 65535
2196; MIPS64EL-NEXT:    sllv $8, $2, $10
2197; MIPS64EL-NEXT:    nor $9, $zero, $8
2198; MIPS64EL-NEXT:    sllv $7, $1, $10
2199; MIPS64EL-NEXT:  .LBB6_1: # %entry
2200; MIPS64EL-NEXT:    # =>This Inner Loop Header: Depth=1
2201; MIPS64EL-NEXT:    ll $2, 0($6)
2202; MIPS64EL-NEXT:    and $2, $2, $8
2203; MIPS64EL-NEXT:    and $7, $7, $8
2204; MIPS64EL-NEXT:    sltu $5, $2, $7
2205; MIPS64EL-NEXT:    move $3, $2
2206; MIPS64EL-NEXT:    movn $3, $7, $5
2207; MIPS64EL-NEXT:    and $3, $3, $8
2208; MIPS64EL-NEXT:    and $4, $2, $9
2209; MIPS64EL-NEXT:    or $4, $4, $3
2210; MIPS64EL-NEXT:    sc $4, 0($6)
2211; MIPS64EL-NEXT:    beqz $4, .LBB6_1
2212; MIPS64EL-NEXT:    nop
2213; MIPS64EL-NEXT:  # %bb.2: # %entry
2214; MIPS64EL-NEXT:    and $1, $2, $8
2215; MIPS64EL-NEXT:    srlv $1, $1, $10
2216; MIPS64EL-NEXT:    seh $1, $1
2217; MIPS64EL-NEXT:  # %bb.3: # %entry
2218; MIPS64EL-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
2219; MIPS64EL-NEXT:  # %bb.4: # %entry
2220; MIPS64EL-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
2221; MIPS64EL-NEXT:    sync
2222; MIPS64EL-NEXT:    daddiu $sp, $sp, 16
2223; MIPS64EL-NEXT:    jr $ra
2224; MIPS64EL-NEXT:    nop
2225;
2226; MIPS64ELR6-LABEL: test_umax_16:
2227; MIPS64ELR6:       # %bb.0: # %entry
2228; MIPS64ELR6-NEXT:    daddiu $sp, $sp, -16
2229; MIPS64ELR6-NEXT:    .cfi_def_cfa_offset 16
2230; MIPS64ELR6-NEXT:    move $1, $5
2231; MIPS64ELR6-NEXT:    sync
2232; MIPS64ELR6-NEXT:    daddiu $2, $zero, -4
2233; MIPS64ELR6-NEXT:    and $6, $4, $2
2234; MIPS64ELR6-NEXT:    andi $2, $4, 3
2235; MIPS64ELR6-NEXT:    sll $10, $2, 3
2236; MIPS64ELR6-NEXT:    ori $2, $zero, 65535
2237; MIPS64ELR6-NEXT:    sllv $8, $2, $10
2238; MIPS64ELR6-NEXT:    nor $9, $zero, $8
2239; MIPS64ELR6-NEXT:    sllv $7, $1, $10
2240; MIPS64ELR6-NEXT:  .LBB6_1: # %entry
2241; MIPS64ELR6-NEXT:    # =>This Inner Loop Header: Depth=1
2242; MIPS64ELR6-NEXT:    ll $2, 0($6)
2243; MIPS64ELR6-NEXT:    and $2, $2, $8
2244; MIPS64ELR6-NEXT:    and $7, $7, $8
2245; MIPS64ELR6-NEXT:    sltu $5, $2, $7
2246; MIPS64ELR6-NEXT:    seleqz $3, $2, $5
2247; MIPS64ELR6-NEXT:    selnez $5, $7, $5
2248; MIPS64ELR6-NEXT:    or $3, $3, $5
2249; MIPS64ELR6-NEXT:    and $3, $3, $8
2250; MIPS64ELR6-NEXT:    and $4, $2, $9
2251; MIPS64ELR6-NEXT:    or $4, $4, $3
2252; MIPS64ELR6-NEXT:    sc $4, 0($6)
2253; MIPS64ELR6-NEXT:    beqzc $4, .LBB6_1
2254; MIPS64ELR6-NEXT:  # %bb.2: # %entry
2255; MIPS64ELR6-NEXT:    and $1, $2, $8
2256; MIPS64ELR6-NEXT:    srlv $1, $1, $10
2257; MIPS64ELR6-NEXT:    seh $1, $1
2258; MIPS64ELR6-NEXT:  # %bb.3: # %entry
2259; MIPS64ELR6-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
2260; MIPS64ELR6-NEXT:  # %bb.4: # %entry
2261; MIPS64ELR6-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
2262; MIPS64ELR6-NEXT:    sync
2263; MIPS64ELR6-NEXT:    daddiu $sp, $sp, 16
2264; MIPS64ELR6-NEXT:    jrc $ra
2265entry:
2266  %0 = atomicrmw umax i16* %ptr, i16 %val seq_cst
2267  ret i16 %0
2268}
2269
2270define i16 @test_umin_16(i16* nocapture %ptr, i16 signext %val) {
2271; MIPS-LABEL: test_umin_16:
2272; MIPS:       # %bb.0: # %entry
2273; MIPS-NEXT:    addiu $sp, $sp, -8
2274; MIPS-NEXT:    .cfi_def_cfa_offset 8
2275; MIPS-NEXT:    # kill: def $at killed $a1
2276; MIPS-NEXT:    sync
2277; MIPS-NEXT:    addiu $1, $zero, -4
2278; MIPS-NEXT:    and $6, $4, $1
2279; MIPS-NEXT:    andi $1, $4, 3
2280; MIPS-NEXT:    xori $1, $1, 2
2281; MIPS-NEXT:    sll $10, $1, 3
2282; MIPS-NEXT:    ori $1, $zero, 65535
2283; MIPS-NEXT:    sllv $8, $1, $10
2284; MIPS-NEXT:    nor $9, $zero, $8
2285; MIPS-NEXT:    sllv $7, $5, $10
2286; MIPS-NEXT:  $BB7_1: # %entry
2287; MIPS-NEXT:    # =>This Inner Loop Header: Depth=1
2288; MIPS-NEXT:    ll $2, 0($6)
2289; MIPS-NEXT:    sltu $5, $2, $7
2290; MIPS-NEXT:    move $3, $2
2291; MIPS-NEXT:    movz $3, $7, $5
2292; MIPS-NEXT:    and $3, $3, $8
2293; MIPS-NEXT:    and $4, $2, $9
2294; MIPS-NEXT:    or $4, $4, $3
2295; MIPS-NEXT:    sc $4, 0($6)
2296; MIPS-NEXT:    beqz $4, $BB7_1
2297; MIPS-NEXT:    nop
2298; MIPS-NEXT:  # %bb.2: # %entry
2299; MIPS-NEXT:    and $1, $2, $8
2300; MIPS-NEXT:    srlv $1, $1, $10
2301; MIPS-NEXT:    seh $1, $1
2302; MIPS-NEXT:  # %bb.3: # %entry
2303; MIPS-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2304; MIPS-NEXT:  # %bb.4: # %entry
2305; MIPS-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
2306; MIPS-NEXT:    sync
2307; MIPS-NEXT:    addiu $sp, $sp, 8
2308; MIPS-NEXT:    jr $ra
2309; MIPS-NEXT:    nop
2310;
2311; MIPSR6-LABEL: test_umin_16:
2312; MIPSR6:       # %bb.0: # %entry
2313; MIPSR6-NEXT:    addiu $sp, $sp, -8
2314; MIPSR6-NEXT:    .cfi_def_cfa_offset 8
2315; MIPSR6-NEXT:    # kill: def $at killed $a1
2316; MIPSR6-NEXT:    sync
2317; MIPSR6-NEXT:    addiu $1, $zero, -4
2318; MIPSR6-NEXT:    and $6, $4, $1
2319; MIPSR6-NEXT:    andi $1, $4, 3
2320; MIPSR6-NEXT:    xori $1, $1, 2
2321; MIPSR6-NEXT:    sll $10, $1, 3
2322; MIPSR6-NEXT:    ori $1, $zero, 65535
2323; MIPSR6-NEXT:    sllv $8, $1, $10
2324; MIPSR6-NEXT:    nor $9, $zero, $8
2325; MIPSR6-NEXT:    sllv $7, $5, $10
2326; MIPSR6-NEXT:  $BB7_1: # %entry
2327; MIPSR6-NEXT:    # =>This Inner Loop Header: Depth=1
2328; MIPSR6-NEXT:    ll $2, 0($6)
2329; MIPSR6-NEXT:    sltu $5, $2, $7
2330; MIPSR6-NEXT:    selnez $3, $2, $5
2331; MIPSR6-NEXT:    seleqz $5, $7, $5
2332; MIPSR6-NEXT:    or $3, $3, $5
2333; MIPSR6-NEXT:    and $3, $3, $8
2334; MIPSR6-NEXT:    and $4, $2, $9
2335; MIPSR6-NEXT:    or $4, $4, $3
2336; MIPSR6-NEXT:    sc $4, 0($6)
2337; MIPSR6-NEXT:    beqzc $4, $BB7_1
2338; MIPSR6-NEXT:  # %bb.2: # %entry
2339; MIPSR6-NEXT:    and $1, $2, $8
2340; MIPSR6-NEXT:    srlv $1, $1, $10
2341; MIPSR6-NEXT:    seh $1, $1
2342; MIPSR6-NEXT:  # %bb.3: # %entry
2343; MIPSR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2344; MIPSR6-NEXT:  # %bb.4: # %entry
2345; MIPSR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
2346; MIPSR6-NEXT:    sync
2347; MIPSR6-NEXT:    addiu $sp, $sp, 8
2348; MIPSR6-NEXT:    jrc $ra
2349;
2350; MM-LABEL: test_umin_16:
2351; MM:       # %bb.0: # %entry
2352; MM-NEXT:    addiu $sp, $sp, -8
2353; MM-NEXT:    .cfi_def_cfa_offset 8
2354; MM-NEXT:    # kill: def $at killed $a1
2355; MM-NEXT:    sync
2356; MM-NEXT:    addiu $1, $zero, -4
2357; MM-NEXT:    and $6, $4, $1
2358; MM-NEXT:    andi $1, $4, 3
2359; MM-NEXT:    xori $1, $1, 2
2360; MM-NEXT:    sll $10, $1, 3
2361; MM-NEXT:    ori $1, $zero, 65535
2362; MM-NEXT:    sllv $8, $1, $10
2363; MM-NEXT:    nor $9, $zero, $8
2364; MM-NEXT:    sllv $7, $5, $10
2365; MM-NEXT:  $BB7_1: # %entry
2366; MM-NEXT:    # =>This Inner Loop Header: Depth=1
2367; MM-NEXT:    ll $2, 0($6)
2368; MM-NEXT:    sltu $5, $2, $7
2369; MM-NEXT:    or $3, $2, $zero
2370; MM-NEXT:    movz $3, $7, $5
2371; MM-NEXT:    and $3, $3, $8
2372; MM-NEXT:    and $4, $2, $9
2373; MM-NEXT:    or $4, $4, $3
2374; MM-NEXT:    sc $4, 0($6)
2375; MM-NEXT:    beqzc $4, $BB7_1
2376; MM-NEXT:  # %bb.2: # %entry
2377; MM-NEXT:    and $1, $2, $8
2378; MM-NEXT:    srlv $1, $1, $10
2379; MM-NEXT:    seh $1, $1
2380; MM-NEXT:  # %bb.3: # %entry
2381; MM-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2382; MM-NEXT:  # %bb.4: # %entry
2383; MM-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
2384; MM-NEXT:    sync
2385; MM-NEXT:    addiusp 8
2386; MM-NEXT:    jrc $ra
2387;
2388; MMR6-LABEL: test_umin_16:
2389; MMR6:       # %bb.0: # %entry
2390; MMR6-NEXT:    addiu $sp, $sp, -8
2391; MMR6-NEXT:    .cfi_def_cfa_offset 8
2392; MMR6-NEXT:    # kill: def $at killed $a1
2393; MMR6-NEXT:    sync
2394; MMR6-NEXT:    addiu $1, $zero, -4
2395; MMR6-NEXT:    and $6, $4, $1
2396; MMR6-NEXT:    andi $1, $4, 3
2397; MMR6-NEXT:    xori $1, $1, 2
2398; MMR6-NEXT:    sll $10, $1, 3
2399; MMR6-NEXT:    ori $1, $zero, 65535
2400; MMR6-NEXT:    sllv $8, $1, $10
2401; MMR6-NEXT:    nor $9, $zero, $8
2402; MMR6-NEXT:    sllv $7, $5, $10
2403; MMR6-NEXT:  $BB7_1: # %entry
2404; MMR6-NEXT:    # =>This Inner Loop Header: Depth=1
2405; MMR6-NEXT:    ll $2, 0($6)
2406; MMR6-NEXT:    sltu $5, $2, $7
2407; MMR6-NEXT:    selnez $3, $2, $5
2408; MMR6-NEXT:    seleqz $5, $7, $5
2409; MMR6-NEXT:    or $3, $3, $5
2410; MMR6-NEXT:    and $3, $3, $8
2411; MMR6-NEXT:    and $4, $2, $9
2412; MMR6-NEXT:    or $4, $4, $3
2413; MMR6-NEXT:    sc $4, 0($6)
2414; MMR6-NEXT:    beqc $4, $zero, $BB7_1
2415; MMR6-NEXT:  # %bb.2: # %entry
2416; MMR6-NEXT:    and $1, $2, $8
2417; MMR6-NEXT:    srlv $1, $1, $10
2418; MMR6-NEXT:    seh $1, $1
2419; MMR6-NEXT:  # %bb.3: # %entry
2420; MMR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2421; MMR6-NEXT:  # %bb.4: # %entry
2422; MMR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
2423; MMR6-NEXT:    sync
2424; MMR6-NEXT:    addiu $sp, $sp, 8
2425; MMR6-NEXT:    jrc $ra
2426;
2427; MIPSEL-LABEL: test_umin_16:
2428; MIPSEL:       # %bb.0: # %entry
2429; MIPSEL-NEXT:    addiu $sp, $sp, -8
2430; MIPSEL-NEXT:    .cfi_def_cfa_offset 8
2431; MIPSEL-NEXT:    # kill: def $at killed $a1
2432; MIPSEL-NEXT:    sync
2433; MIPSEL-NEXT:    addiu $1, $zero, -4
2434; MIPSEL-NEXT:    and $6, $4, $1
2435; MIPSEL-NEXT:    andi $1, $4, 3
2436; MIPSEL-NEXT:    sll $10, $1, 3
2437; MIPSEL-NEXT:    ori $1, $zero, 65535
2438; MIPSEL-NEXT:    sllv $8, $1, $10
2439; MIPSEL-NEXT:    nor $9, $zero, $8
2440; MIPSEL-NEXT:    sllv $7, $5, $10
2441; MIPSEL-NEXT:  $BB7_1: # %entry
2442; MIPSEL-NEXT:    # =>This Inner Loop Header: Depth=1
2443; MIPSEL-NEXT:    ll $2, 0($6)
2444; MIPSEL-NEXT:    and $2, $2, $8
2445; MIPSEL-NEXT:    and $7, $7, $8
2446; MIPSEL-NEXT:    sltu $5, $2, $7
2447; MIPSEL-NEXT:    move $3, $2
2448; MIPSEL-NEXT:    movz $3, $7, $5
2449; MIPSEL-NEXT:    and $3, $3, $8
2450; MIPSEL-NEXT:    and $4, $2, $9
2451; MIPSEL-NEXT:    or $4, $4, $3
2452; MIPSEL-NEXT:    sc $4, 0($6)
2453; MIPSEL-NEXT:    beqz $4, $BB7_1
2454; MIPSEL-NEXT:    nop
2455; MIPSEL-NEXT:  # %bb.2: # %entry
2456; MIPSEL-NEXT:    and $1, $2, $8
2457; MIPSEL-NEXT:    srlv $1, $1, $10
2458; MIPSEL-NEXT:    seh $1, $1
2459; MIPSEL-NEXT:  # %bb.3: # %entry
2460; MIPSEL-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2461; MIPSEL-NEXT:  # %bb.4: # %entry
2462; MIPSEL-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
2463; MIPSEL-NEXT:    sync
2464; MIPSEL-NEXT:    addiu $sp, $sp, 8
2465; MIPSEL-NEXT:    jr $ra
2466; MIPSEL-NEXT:    nop
2467;
2468; MIPSELR6-LABEL: test_umin_16:
2469; MIPSELR6:       # %bb.0: # %entry
2470; MIPSELR6-NEXT:    addiu $sp, $sp, -8
2471; MIPSELR6-NEXT:    .cfi_def_cfa_offset 8
2472; MIPSELR6-NEXT:    # kill: def $at killed $a1
2473; MIPSELR6-NEXT:    sync
2474; MIPSELR6-NEXT:    addiu $1, $zero, -4
2475; MIPSELR6-NEXT:    and $6, $4, $1
2476; MIPSELR6-NEXT:    andi $1, $4, 3
2477; MIPSELR6-NEXT:    sll $10, $1, 3
2478; MIPSELR6-NEXT:    ori $1, $zero, 65535
2479; MIPSELR6-NEXT:    sllv $8, $1, $10
2480; MIPSELR6-NEXT:    nor $9, $zero, $8
2481; MIPSELR6-NEXT:    sllv $7, $5, $10
2482; MIPSELR6-NEXT:  $BB7_1: # %entry
2483; MIPSELR6-NEXT:    # =>This Inner Loop Header: Depth=1
2484; MIPSELR6-NEXT:    ll $2, 0($6)
2485; MIPSELR6-NEXT:    and $2, $2, $8
2486; MIPSELR6-NEXT:    and $7, $7, $8
2487; MIPSELR6-NEXT:    sltu $5, $2, $7
2488; MIPSELR6-NEXT:    selnez $3, $2, $5
2489; MIPSELR6-NEXT:    seleqz $5, $7, $5
2490; MIPSELR6-NEXT:    or $3, $3, $5
2491; MIPSELR6-NEXT:    and $3, $3, $8
2492; MIPSELR6-NEXT:    and $4, $2, $9
2493; MIPSELR6-NEXT:    or $4, $4, $3
2494; MIPSELR6-NEXT:    sc $4, 0($6)
2495; MIPSELR6-NEXT:    beqzc $4, $BB7_1
2496; MIPSELR6-NEXT:  # %bb.2: # %entry
2497; MIPSELR6-NEXT:    and $1, $2, $8
2498; MIPSELR6-NEXT:    srlv $1, $1, $10
2499; MIPSELR6-NEXT:    seh $1, $1
2500; MIPSELR6-NEXT:  # %bb.3: # %entry
2501; MIPSELR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2502; MIPSELR6-NEXT:  # %bb.4: # %entry
2503; MIPSELR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
2504; MIPSELR6-NEXT:    sync
2505; MIPSELR6-NEXT:    addiu $sp, $sp, 8
2506; MIPSELR6-NEXT:    jrc $ra
2507;
2508; MMEL-LABEL: test_umin_16:
2509; MMEL:       # %bb.0: # %entry
2510; MMEL-NEXT:    addiu $sp, $sp, -8
2511; MMEL-NEXT:    .cfi_def_cfa_offset 8
2512; MMEL-NEXT:    # kill: def $at killed $a1
2513; MMEL-NEXT:    sync
2514; MMEL-NEXT:    addiu $1, $zero, -4
2515; MMEL-NEXT:    and $6, $4, $1
2516; MMEL-NEXT:    andi $1, $4, 3
2517; MMEL-NEXT:    sll $10, $1, 3
2518; MMEL-NEXT:    ori $1, $zero, 65535
2519; MMEL-NEXT:    sllv $8, $1, $10
2520; MMEL-NEXT:    nor $9, $zero, $8
2521; MMEL-NEXT:    sllv $7, $5, $10
2522; MMEL-NEXT:  $BB7_1: # %entry
2523; MMEL-NEXT:    # =>This Inner Loop Header: Depth=1
2524; MMEL-NEXT:    ll $2, 0($6)
2525; MMEL-NEXT:    and $2, $2, $8
2526; MMEL-NEXT:    and $7, $7, $8
2527; MMEL-NEXT:    sltu $5, $2, $7
2528; MMEL-NEXT:    or $3, $2, $zero
2529; MMEL-NEXT:    movz $3, $7, $5
2530; MMEL-NEXT:    and $3, $3, $8
2531; MMEL-NEXT:    and $4, $2, $9
2532; MMEL-NEXT:    or $4, $4, $3
2533; MMEL-NEXT:    sc $4, 0($6)
2534; MMEL-NEXT:    beqzc $4, $BB7_1
2535; MMEL-NEXT:  # %bb.2: # %entry
2536; MMEL-NEXT:    and $1, $2, $8
2537; MMEL-NEXT:    srlv $1, $1, $10
2538; MMEL-NEXT:    seh $1, $1
2539; MMEL-NEXT:  # %bb.3: # %entry
2540; MMEL-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2541; MMEL-NEXT:  # %bb.4: # %entry
2542; MMEL-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
2543; MMEL-NEXT:    sync
2544; MMEL-NEXT:    addiusp 8
2545; MMEL-NEXT:    jrc $ra
2546;
2547; MMELR6-LABEL: test_umin_16:
2548; MMELR6:       # %bb.0: # %entry
2549; MMELR6-NEXT:    addiu $sp, $sp, -8
2550; MMELR6-NEXT:    .cfi_def_cfa_offset 8
2551; MMELR6-NEXT:    # kill: def $at killed $a1
2552; MMELR6-NEXT:    sync
2553; MMELR6-NEXT:    addiu $1, $zero, -4
2554; MMELR6-NEXT:    and $6, $4, $1
2555; MMELR6-NEXT:    andi $1, $4, 3
2556; MMELR6-NEXT:    sll $10, $1, 3
2557; MMELR6-NEXT:    ori $1, $zero, 65535
2558; MMELR6-NEXT:    sllv $8, $1, $10
2559; MMELR6-NEXT:    nor $9, $zero, $8
2560; MMELR6-NEXT:    sllv $7, $5, $10
2561; MMELR6-NEXT:  $BB7_1: # %entry
2562; MMELR6-NEXT:    # =>This Inner Loop Header: Depth=1
2563; MMELR6-NEXT:    ll $2, 0($6)
2564; MMELR6-NEXT:    and $2, $2, $8
2565; MMELR6-NEXT:    and $7, $7, $8
2566; MMELR6-NEXT:    sltu $5, $2, $7
2567; MMELR6-NEXT:    selnez $3, $2, $5
2568; MMELR6-NEXT:    seleqz $5, $7, $5
2569; MMELR6-NEXT:    or $3, $3, $5
2570; MMELR6-NEXT:    and $3, $3, $8
2571; MMELR6-NEXT:    and $4, $2, $9
2572; MMELR6-NEXT:    or $4, $4, $3
2573; MMELR6-NEXT:    sc $4, 0($6)
2574; MMELR6-NEXT:    beqc $4, $zero, $BB7_1
2575; MMELR6-NEXT:  # %bb.2: # %entry
2576; MMELR6-NEXT:    and $1, $2, $8
2577; MMELR6-NEXT:    srlv $1, $1, $10
2578; MMELR6-NEXT:    seh $1, $1
2579; MMELR6-NEXT:  # %bb.3: # %entry
2580; MMELR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2581; MMELR6-NEXT:  # %bb.4: # %entry
2582; MMELR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
2583; MMELR6-NEXT:    sync
2584; MMELR6-NEXT:    addiu $sp, $sp, 8
2585; MMELR6-NEXT:    jrc $ra
2586;
2587; MIPS64-LABEL: test_umin_16:
2588; MIPS64:       # %bb.0: # %entry
2589; MIPS64-NEXT:    daddiu $sp, $sp, -16
2590; MIPS64-NEXT:    .cfi_def_cfa_offset 16
2591; MIPS64-NEXT:    move $1, $5
2592; MIPS64-NEXT:    sync
2593; MIPS64-NEXT:    daddiu $2, $zero, -4
2594; MIPS64-NEXT:    and $6, $4, $2
2595; MIPS64-NEXT:    andi $2, $4, 3
2596; MIPS64-NEXT:    xori $2, $2, 2
2597; MIPS64-NEXT:    sll $10, $2, 3
2598; MIPS64-NEXT:    ori $2, $zero, 65535
2599; MIPS64-NEXT:    sllv $8, $2, $10
2600; MIPS64-NEXT:    nor $9, $zero, $8
2601; MIPS64-NEXT:    sllv $7, $1, $10
2602; MIPS64-NEXT:  .LBB7_1: # %entry
2603; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
2604; MIPS64-NEXT:    ll $2, 0($6)
2605; MIPS64-NEXT:    sltu $5, $2, $7
2606; MIPS64-NEXT:    move $3, $2
2607; MIPS64-NEXT:    movz $3, $7, $5
2608; MIPS64-NEXT:    and $3, $3, $8
2609; MIPS64-NEXT:    and $4, $2, $9
2610; MIPS64-NEXT:    or $4, $4, $3
2611; MIPS64-NEXT:    sc $4, 0($6)
2612; MIPS64-NEXT:    beqz $4, .LBB7_1
2613; MIPS64-NEXT:    nop
2614; MIPS64-NEXT:  # %bb.2: # %entry
2615; MIPS64-NEXT:    and $1, $2, $8
2616; MIPS64-NEXT:    srlv $1, $1, $10
2617; MIPS64-NEXT:    seh $1, $1
2618; MIPS64-NEXT:  # %bb.3: # %entry
2619; MIPS64-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
2620; MIPS64-NEXT:  # %bb.4: # %entry
2621; MIPS64-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
2622; MIPS64-NEXT:    sync
2623; MIPS64-NEXT:    daddiu $sp, $sp, 16
2624; MIPS64-NEXT:    jr $ra
2625; MIPS64-NEXT:    nop
2626;
2627; MIPS64R6-LABEL: test_umin_16:
2628; MIPS64R6:       # %bb.0: # %entry
2629; MIPS64R6-NEXT:    daddiu $sp, $sp, -16
2630; MIPS64R6-NEXT:    .cfi_def_cfa_offset 16
2631; MIPS64R6-NEXT:    move $1, $5
2632; MIPS64R6-NEXT:    sync
2633; MIPS64R6-NEXT:    daddiu $2, $zero, -4
2634; MIPS64R6-NEXT:    and $6, $4, $2
2635; MIPS64R6-NEXT:    andi $2, $4, 3
2636; MIPS64R6-NEXT:    xori $2, $2, 2
2637; MIPS64R6-NEXT:    sll $10, $2, 3
2638; MIPS64R6-NEXT:    ori $2, $zero, 65535
2639; MIPS64R6-NEXT:    sllv $8, $2, $10
2640; MIPS64R6-NEXT:    nor $9, $zero, $8
2641; MIPS64R6-NEXT:    sllv $7, $1, $10
2642; MIPS64R6-NEXT:  .LBB7_1: # %entry
2643; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
2644; MIPS64R6-NEXT:    ll $2, 0($6)
2645; MIPS64R6-NEXT:    sltu $5, $2, $7
2646; MIPS64R6-NEXT:    selnez $3, $2, $5
2647; MIPS64R6-NEXT:    seleqz $5, $7, $5
2648; MIPS64R6-NEXT:    or $3, $3, $5
2649; MIPS64R6-NEXT:    and $3, $3, $8
2650; MIPS64R6-NEXT:    and $4, $2, $9
2651; MIPS64R6-NEXT:    or $4, $4, $3
2652; MIPS64R6-NEXT:    sc $4, 0($6)
2653; MIPS64R6-NEXT:    beqzc $4, .LBB7_1
2654; MIPS64R6-NEXT:  # %bb.2: # %entry
2655; MIPS64R6-NEXT:    and $1, $2, $8
2656; MIPS64R6-NEXT:    srlv $1, $1, $10
2657; MIPS64R6-NEXT:    seh $1, $1
2658; MIPS64R6-NEXT:  # %bb.3: # %entry
2659; MIPS64R6-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
2660; MIPS64R6-NEXT:  # %bb.4: # %entry
2661; MIPS64R6-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
2662; MIPS64R6-NEXT:    sync
2663; MIPS64R6-NEXT:    daddiu $sp, $sp, 16
2664; MIPS64R6-NEXT:    jrc $ra
2665;
2666; MIPS64EL-LABEL: test_umin_16:
2667; MIPS64EL:       # %bb.0: # %entry
2668; MIPS64EL-NEXT:    daddiu $sp, $sp, -16
2669; MIPS64EL-NEXT:    .cfi_def_cfa_offset 16
2670; MIPS64EL-NEXT:    move $1, $5
2671; MIPS64EL-NEXT:    sync
2672; MIPS64EL-NEXT:    daddiu $2, $zero, -4
2673; MIPS64EL-NEXT:    and $6, $4, $2
2674; MIPS64EL-NEXT:    andi $2, $4, 3
2675; MIPS64EL-NEXT:    sll $10, $2, 3
2676; MIPS64EL-NEXT:    ori $2, $zero, 65535
2677; MIPS64EL-NEXT:    sllv $8, $2, $10
2678; MIPS64EL-NEXT:    nor $9, $zero, $8
2679; MIPS64EL-NEXT:    sllv $7, $1, $10
2680; MIPS64EL-NEXT:  .LBB7_1: # %entry
2681; MIPS64EL-NEXT:    # =>This Inner Loop Header: Depth=1
2682; MIPS64EL-NEXT:    ll $2, 0($6)
2683; MIPS64EL-NEXT:    and $2, $2, $8
2684; MIPS64EL-NEXT:    and $7, $7, $8
2685; MIPS64EL-NEXT:    sltu $5, $2, $7
2686; MIPS64EL-NEXT:    move $3, $2
2687; MIPS64EL-NEXT:    movz $3, $7, $5
2688; MIPS64EL-NEXT:    and $3, $3, $8
2689; MIPS64EL-NEXT:    and $4, $2, $9
2690; MIPS64EL-NEXT:    or $4, $4, $3
2691; MIPS64EL-NEXT:    sc $4, 0($6)
2692; MIPS64EL-NEXT:    beqz $4, .LBB7_1
2693; MIPS64EL-NEXT:    nop
2694; MIPS64EL-NEXT:  # %bb.2: # %entry
2695; MIPS64EL-NEXT:    and $1, $2, $8
2696; MIPS64EL-NEXT:    srlv $1, $1, $10
2697; MIPS64EL-NEXT:    seh $1, $1
2698; MIPS64EL-NEXT:  # %bb.3: # %entry
2699; MIPS64EL-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
2700; MIPS64EL-NEXT:  # %bb.4: # %entry
2701; MIPS64EL-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
2702; MIPS64EL-NEXT:    sync
2703; MIPS64EL-NEXT:    daddiu $sp, $sp, 16
2704; MIPS64EL-NEXT:    jr $ra
2705; MIPS64EL-NEXT:    nop
2706;
2707; MIPS64ELR6-LABEL: test_umin_16:
2708; MIPS64ELR6:       # %bb.0: # %entry
2709; MIPS64ELR6-NEXT:    daddiu $sp, $sp, -16
2710; MIPS64ELR6-NEXT:    .cfi_def_cfa_offset 16
2711; MIPS64ELR6-NEXT:    move $1, $5
2712; MIPS64ELR6-NEXT:    sync
2713; MIPS64ELR6-NEXT:    daddiu $2, $zero, -4
2714; MIPS64ELR6-NEXT:    and $6, $4, $2
2715; MIPS64ELR6-NEXT:    andi $2, $4, 3
2716; MIPS64ELR6-NEXT:    sll $10, $2, 3
2717; MIPS64ELR6-NEXT:    ori $2, $zero, 65535
2718; MIPS64ELR6-NEXT:    sllv $8, $2, $10
2719; MIPS64ELR6-NEXT:    nor $9, $zero, $8
2720; MIPS64ELR6-NEXT:    sllv $7, $1, $10
2721; MIPS64ELR6-NEXT:  .LBB7_1: # %entry
2722; MIPS64ELR6-NEXT:    # =>This Inner Loop Header: Depth=1
2723; MIPS64ELR6-NEXT:    ll $2, 0($6)
2724; MIPS64ELR6-NEXT:    and $2, $2, $8
2725; MIPS64ELR6-NEXT:    and $7, $7, $8
2726; MIPS64ELR6-NEXT:    sltu $5, $2, $7
2727; MIPS64ELR6-NEXT:    selnez $3, $2, $5
2728; MIPS64ELR6-NEXT:    seleqz $5, $7, $5
2729; MIPS64ELR6-NEXT:    or $3, $3, $5
2730; MIPS64ELR6-NEXT:    and $3, $3, $8
2731; MIPS64ELR6-NEXT:    and $4, $2, $9
2732; MIPS64ELR6-NEXT:    or $4, $4, $3
2733; MIPS64ELR6-NEXT:    sc $4, 0($6)
2734; MIPS64ELR6-NEXT:    beqzc $4, .LBB7_1
2735; MIPS64ELR6-NEXT:  # %bb.2: # %entry
2736; MIPS64ELR6-NEXT:    and $1, $2, $8
2737; MIPS64ELR6-NEXT:    srlv $1, $1, $10
2738; MIPS64ELR6-NEXT:    seh $1, $1
2739; MIPS64ELR6-NEXT:  # %bb.3: # %entry
2740; MIPS64ELR6-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
2741; MIPS64ELR6-NEXT:  # %bb.4: # %entry
2742; MIPS64ELR6-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
2743; MIPS64ELR6-NEXT:    sync
2744; MIPS64ELR6-NEXT:    daddiu $sp, $sp, 16
2745; MIPS64ELR6-NEXT:    jrc $ra
2746entry:
2747  %0 = atomicrmw umin i16* %ptr, i16 %val seq_cst
2748  ret i16 %0
2749}
2750
2751
2752define i8 @test_max_8(i8* nocapture %ptr, i8 signext %val) {
2753; MIPS-LABEL: test_max_8:
2754; MIPS:       # %bb.0: # %entry
2755; MIPS-NEXT:    addiu $sp, $sp, -8
2756; MIPS-NEXT:    .cfi_def_cfa_offset 8
2757; MIPS-NEXT:    # kill: def $at killed $a1
2758; MIPS-NEXT:    sync
2759; MIPS-NEXT:    addiu $1, $zero, -4
2760; MIPS-NEXT:    and $6, $4, $1
2761; MIPS-NEXT:    andi $1, $4, 3
2762; MIPS-NEXT:    xori $1, $1, 3
2763; MIPS-NEXT:    sll $10, $1, 3
2764; MIPS-NEXT:    ori $1, $zero, 255
2765; MIPS-NEXT:    sllv $8, $1, $10
2766; MIPS-NEXT:    nor $9, $zero, $8
2767; MIPS-NEXT:    sllv $7, $5, $10
2768; MIPS-NEXT:  $BB8_1: # %entry
2769; MIPS-NEXT:    # =>This Inner Loop Header: Depth=1
2770; MIPS-NEXT:    ll $2, 0($6)
2771; MIPS-NEXT:    slt $5, $2, $7
2772; MIPS-NEXT:    move $3, $2
2773; MIPS-NEXT:    movn $3, $7, $5
2774; MIPS-NEXT:    and $3, $3, $8
2775; MIPS-NEXT:    and $4, $2, $9
2776; MIPS-NEXT:    or $4, $4, $3
2777; MIPS-NEXT:    sc $4, 0($6)
2778; MIPS-NEXT:    beqz $4, $BB8_1
2779; MIPS-NEXT:    nop
2780; MIPS-NEXT:  # %bb.2: # %entry
2781; MIPS-NEXT:    and $1, $2, $8
2782; MIPS-NEXT:    srlv $1, $1, $10
2783; MIPS-NEXT:    seh $1, $1
2784; MIPS-NEXT:  # %bb.3: # %entry
2785; MIPS-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2786; MIPS-NEXT:  # %bb.4: # %entry
2787; MIPS-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
2788; MIPS-NEXT:    sync
2789; MIPS-NEXT:    addiu $sp, $sp, 8
2790; MIPS-NEXT:    jr $ra
2791; MIPS-NEXT:    nop
2792;
2793; MIPSR6-LABEL: test_max_8:
2794; MIPSR6:       # %bb.0: # %entry
2795; MIPSR6-NEXT:    addiu $sp, $sp, -8
2796; MIPSR6-NEXT:    .cfi_def_cfa_offset 8
2797; MIPSR6-NEXT:    # kill: def $at killed $a1
2798; MIPSR6-NEXT:    sync
2799; MIPSR6-NEXT:    addiu $1, $zero, -4
2800; MIPSR6-NEXT:    and $6, $4, $1
2801; MIPSR6-NEXT:    andi $1, $4, 3
2802; MIPSR6-NEXT:    xori $1, $1, 3
2803; MIPSR6-NEXT:    sll $10, $1, 3
2804; MIPSR6-NEXT:    ori $1, $zero, 255
2805; MIPSR6-NEXT:    sllv $8, $1, $10
2806; MIPSR6-NEXT:    nor $9, $zero, $8
2807; MIPSR6-NEXT:    sllv $7, $5, $10
2808; MIPSR6-NEXT:  $BB8_1: # %entry
2809; MIPSR6-NEXT:    # =>This Inner Loop Header: Depth=1
2810; MIPSR6-NEXT:    ll $2, 0($6)
2811; MIPSR6-NEXT:    slt $5, $2, $7
2812; MIPSR6-NEXT:    seleqz $3, $2, $5
2813; MIPSR6-NEXT:    selnez $5, $7, $5
2814; MIPSR6-NEXT:    or $3, $3, $5
2815; MIPSR6-NEXT:    and $3, $3, $8
2816; MIPSR6-NEXT:    and $4, $2, $9
2817; MIPSR6-NEXT:    or $4, $4, $3
2818; MIPSR6-NEXT:    sc $4, 0($6)
2819; MIPSR6-NEXT:    beqzc $4, $BB8_1
2820; MIPSR6-NEXT:  # %bb.2: # %entry
2821; MIPSR6-NEXT:    and $1, $2, $8
2822; MIPSR6-NEXT:    srlv $1, $1, $10
2823; MIPSR6-NEXT:    seh $1, $1
2824; MIPSR6-NEXT:  # %bb.3: # %entry
2825; MIPSR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2826; MIPSR6-NEXT:  # %bb.4: # %entry
2827; MIPSR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
2828; MIPSR6-NEXT:    sync
2829; MIPSR6-NEXT:    addiu $sp, $sp, 8
2830; MIPSR6-NEXT:    jrc $ra
2831;
2832; MM-LABEL: test_max_8:
2833; MM:       # %bb.0: # %entry
2834; MM-NEXT:    addiu $sp, $sp, -8
2835; MM-NEXT:    .cfi_def_cfa_offset 8
2836; MM-NEXT:    # kill: def $at killed $a1
2837; MM-NEXT:    sync
2838; MM-NEXT:    addiu $1, $zero, -4
2839; MM-NEXT:    and $6, $4, $1
2840; MM-NEXT:    andi $1, $4, 3
2841; MM-NEXT:    xori $1, $1, 3
2842; MM-NEXT:    sll $10, $1, 3
2843; MM-NEXT:    ori $1, $zero, 255
2844; MM-NEXT:    sllv $8, $1, $10
2845; MM-NEXT:    nor $9, $zero, $8
2846; MM-NEXT:    sllv $7, $5, $10
2847; MM-NEXT:  $BB8_1: # %entry
2848; MM-NEXT:    # =>This Inner Loop Header: Depth=1
2849; MM-NEXT:    ll $2, 0($6)
2850; MM-NEXT:    slt $5, $2, $7
2851; MM-NEXT:    or $3, $2, $zero
2852; MM-NEXT:    movn $3, $7, $5
2853; MM-NEXT:    and $3, $3, $8
2854; MM-NEXT:    and $4, $2, $9
2855; MM-NEXT:    or $4, $4, $3
2856; MM-NEXT:    sc $4, 0($6)
2857; MM-NEXT:    beqzc $4, $BB8_1
2858; MM-NEXT:  # %bb.2: # %entry
2859; MM-NEXT:    and $1, $2, $8
2860; MM-NEXT:    srlv $1, $1, $10
2861; MM-NEXT:    seh $1, $1
2862; MM-NEXT:  # %bb.3: # %entry
2863; MM-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2864; MM-NEXT:  # %bb.4: # %entry
2865; MM-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
2866; MM-NEXT:    sync
2867; MM-NEXT:    addiusp 8
2868; MM-NEXT:    jrc $ra
2869;
2870; MMR6-LABEL: test_max_8:
2871; MMR6:       # %bb.0: # %entry
2872; MMR6-NEXT:    addiu $sp, $sp, -8
2873; MMR6-NEXT:    .cfi_def_cfa_offset 8
2874; MMR6-NEXT:    # kill: def $at killed $a1
2875; MMR6-NEXT:    sync
2876; MMR6-NEXT:    addiu $1, $zero, -4
2877; MMR6-NEXT:    and $6, $4, $1
2878; MMR6-NEXT:    andi $1, $4, 3
2879; MMR6-NEXT:    xori $1, $1, 3
2880; MMR6-NEXT:    sll $10, $1, 3
2881; MMR6-NEXT:    ori $1, $zero, 255
2882; MMR6-NEXT:    sllv $8, $1, $10
2883; MMR6-NEXT:    nor $9, $zero, $8
2884; MMR6-NEXT:    sllv $7, $5, $10
2885; MMR6-NEXT:  $BB8_1: # %entry
2886; MMR6-NEXT:    # =>This Inner Loop Header: Depth=1
2887; MMR6-NEXT:    ll $2, 0($6)
2888; MMR6-NEXT:    slt $5, $2, $7
2889; MMR6-NEXT:    seleqz $3, $2, $5
2890; MMR6-NEXT:    selnez $5, $7, $5
2891; MMR6-NEXT:    or $3, $3, $5
2892; MMR6-NEXT:    and $3, $3, $8
2893; MMR6-NEXT:    and $4, $2, $9
2894; MMR6-NEXT:    or $4, $4, $3
2895; MMR6-NEXT:    sc $4, 0($6)
2896; MMR6-NEXT:    beqc $4, $zero, $BB8_1
2897; MMR6-NEXT:  # %bb.2: # %entry
2898; MMR6-NEXT:    and $1, $2, $8
2899; MMR6-NEXT:    srlv $1, $1, $10
2900; MMR6-NEXT:    seh $1, $1
2901; MMR6-NEXT:  # %bb.3: # %entry
2902; MMR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2903; MMR6-NEXT:  # %bb.4: # %entry
2904; MMR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
2905; MMR6-NEXT:    sync
2906; MMR6-NEXT:    addiu $sp, $sp, 8
2907; MMR6-NEXT:    jrc $ra
2908;
2909; MIPSEL-LABEL: test_max_8:
2910; MIPSEL:       # %bb.0: # %entry
2911; MIPSEL-NEXT:    addiu $sp, $sp, -8
2912; MIPSEL-NEXT:    .cfi_def_cfa_offset 8
2913; MIPSEL-NEXT:    # kill: def $at killed $a1
2914; MIPSEL-NEXT:    sync
2915; MIPSEL-NEXT:    addiu $1, $zero, -4
2916; MIPSEL-NEXT:    and $6, $4, $1
2917; MIPSEL-NEXT:    andi $1, $4, 3
2918; MIPSEL-NEXT:    sll $10, $1, 3
2919; MIPSEL-NEXT:    ori $1, $zero, 255
2920; MIPSEL-NEXT:    sllv $8, $1, $10
2921; MIPSEL-NEXT:    nor $9, $zero, $8
2922; MIPSEL-NEXT:    sllv $7, $5, $10
2923; MIPSEL-NEXT:  $BB8_1: # %entry
2924; MIPSEL-NEXT:    # =>This Inner Loop Header: Depth=1
2925; MIPSEL-NEXT:    ll $2, 0($6)
2926; MIPSEL-NEXT:    and $2, $2, $8
2927; MIPSEL-NEXT:    and $7, $7, $8
2928; MIPSEL-NEXT:    slt $5, $2, $7
2929; MIPSEL-NEXT:    move $3, $2
2930; MIPSEL-NEXT:    movn $3, $7, $5
2931; MIPSEL-NEXT:    and $3, $3, $8
2932; MIPSEL-NEXT:    and $4, $2, $9
2933; MIPSEL-NEXT:    or $4, $4, $3
2934; MIPSEL-NEXT:    sc $4, 0($6)
2935; MIPSEL-NEXT:    beqz $4, $BB8_1
2936; MIPSEL-NEXT:    nop
2937; MIPSEL-NEXT:  # %bb.2: # %entry
2938; MIPSEL-NEXT:    and $1, $2, $8
2939; MIPSEL-NEXT:    srlv $1, $1, $10
2940; MIPSEL-NEXT:    seh $1, $1
2941; MIPSEL-NEXT:  # %bb.3: # %entry
2942; MIPSEL-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2943; MIPSEL-NEXT:  # %bb.4: # %entry
2944; MIPSEL-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
2945; MIPSEL-NEXT:    sync
2946; MIPSEL-NEXT:    addiu $sp, $sp, 8
2947; MIPSEL-NEXT:    jr $ra
2948; MIPSEL-NEXT:    nop
2949;
2950; MIPSELR6-LABEL: test_max_8:
2951; MIPSELR6:       # %bb.0: # %entry
2952; MIPSELR6-NEXT:    addiu $sp, $sp, -8
2953; MIPSELR6-NEXT:    .cfi_def_cfa_offset 8
2954; MIPSELR6-NEXT:    # kill: def $at killed $a1
2955; MIPSELR6-NEXT:    sync
2956; MIPSELR6-NEXT:    addiu $1, $zero, -4
2957; MIPSELR6-NEXT:    and $6, $4, $1
2958; MIPSELR6-NEXT:    andi $1, $4, 3
2959; MIPSELR6-NEXT:    sll $10, $1, 3
2960; MIPSELR6-NEXT:    ori $1, $zero, 255
2961; MIPSELR6-NEXT:    sllv $8, $1, $10
2962; MIPSELR6-NEXT:    nor $9, $zero, $8
2963; MIPSELR6-NEXT:    sllv $7, $5, $10
2964; MIPSELR6-NEXT:  $BB8_1: # %entry
2965; MIPSELR6-NEXT:    # =>This Inner Loop Header: Depth=1
2966; MIPSELR6-NEXT:    ll $2, 0($6)
2967; MIPSELR6-NEXT:    and $2, $2, $8
2968; MIPSELR6-NEXT:    and $7, $7, $8
2969; MIPSELR6-NEXT:    slt $5, $2, $7
2970; MIPSELR6-NEXT:    seleqz $3, $2, $5
2971; MIPSELR6-NEXT:    selnez $5, $7, $5
2972; MIPSELR6-NEXT:    or $3, $3, $5
2973; MIPSELR6-NEXT:    and $3, $3, $8
2974; MIPSELR6-NEXT:    and $4, $2, $9
2975; MIPSELR6-NEXT:    or $4, $4, $3
2976; MIPSELR6-NEXT:    sc $4, 0($6)
2977; MIPSELR6-NEXT:    beqzc $4, $BB8_1
2978; MIPSELR6-NEXT:  # %bb.2: # %entry
2979; MIPSELR6-NEXT:    and $1, $2, $8
2980; MIPSELR6-NEXT:    srlv $1, $1, $10
2981; MIPSELR6-NEXT:    seh $1, $1
2982; MIPSELR6-NEXT:  # %bb.3: # %entry
2983; MIPSELR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
2984; MIPSELR6-NEXT:  # %bb.4: # %entry
2985; MIPSELR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
2986; MIPSELR6-NEXT:    sync
2987; MIPSELR6-NEXT:    addiu $sp, $sp, 8
2988; MIPSELR6-NEXT:    jrc $ra
2989;
2990; MMEL-LABEL: test_max_8:
2991; MMEL:       # %bb.0: # %entry
2992; MMEL-NEXT:    addiu $sp, $sp, -8
2993; MMEL-NEXT:    .cfi_def_cfa_offset 8
2994; MMEL-NEXT:    # kill: def $at killed $a1
2995; MMEL-NEXT:    sync
2996; MMEL-NEXT:    addiu $1, $zero, -4
2997; MMEL-NEXT:    and $6, $4, $1
2998; MMEL-NEXT:    andi $1, $4, 3
2999; MMEL-NEXT:    sll $10, $1, 3
3000; MMEL-NEXT:    ori $1, $zero, 255
3001; MMEL-NEXT:    sllv $8, $1, $10
3002; MMEL-NEXT:    nor $9, $zero, $8
3003; MMEL-NEXT:    sllv $7, $5, $10
3004; MMEL-NEXT:  $BB8_1: # %entry
3005; MMEL-NEXT:    # =>This Inner Loop Header: Depth=1
3006; MMEL-NEXT:    ll $2, 0($6)
3007; MMEL-NEXT:    and $2, $2, $8
3008; MMEL-NEXT:    and $7, $7, $8
3009; MMEL-NEXT:    slt $5, $2, $7
3010; MMEL-NEXT:    or $3, $2, $zero
3011; MMEL-NEXT:    movn $3, $7, $5
3012; MMEL-NEXT:    and $3, $3, $8
3013; MMEL-NEXT:    and $4, $2, $9
3014; MMEL-NEXT:    or $4, $4, $3
3015; MMEL-NEXT:    sc $4, 0($6)
3016; MMEL-NEXT:    beqzc $4, $BB8_1
3017; MMEL-NEXT:  # %bb.2: # %entry
3018; MMEL-NEXT:    and $1, $2, $8
3019; MMEL-NEXT:    srlv $1, $1, $10
3020; MMEL-NEXT:    seh $1, $1
3021; MMEL-NEXT:  # %bb.3: # %entry
3022; MMEL-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3023; MMEL-NEXT:  # %bb.4: # %entry
3024; MMEL-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
3025; MMEL-NEXT:    sync
3026; MMEL-NEXT:    addiusp 8
3027; MMEL-NEXT:    jrc $ra
3028;
3029; MMELR6-LABEL: test_max_8:
3030; MMELR6:       # %bb.0: # %entry
3031; MMELR6-NEXT:    addiu $sp, $sp, -8
3032; MMELR6-NEXT:    .cfi_def_cfa_offset 8
3033; MMELR6-NEXT:    # kill: def $at killed $a1
3034; MMELR6-NEXT:    sync
3035; MMELR6-NEXT:    addiu $1, $zero, -4
3036; MMELR6-NEXT:    and $6, $4, $1
3037; MMELR6-NEXT:    andi $1, $4, 3
3038; MMELR6-NEXT:    sll $10, $1, 3
3039; MMELR6-NEXT:    ori $1, $zero, 255
3040; MMELR6-NEXT:    sllv $8, $1, $10
3041; MMELR6-NEXT:    nor $9, $zero, $8
3042; MMELR6-NEXT:    sllv $7, $5, $10
3043; MMELR6-NEXT:  $BB8_1: # %entry
3044; MMELR6-NEXT:    # =>This Inner Loop Header: Depth=1
3045; MMELR6-NEXT:    ll $2, 0($6)
3046; MMELR6-NEXT:    and $2, $2, $8
3047; MMELR6-NEXT:    and $7, $7, $8
3048; MMELR6-NEXT:    slt $5, $2, $7
3049; MMELR6-NEXT:    seleqz $3, $2, $5
3050; MMELR6-NEXT:    selnez $5, $7, $5
3051; MMELR6-NEXT:    or $3, $3, $5
3052; MMELR6-NEXT:    and $3, $3, $8
3053; MMELR6-NEXT:    and $4, $2, $9
3054; MMELR6-NEXT:    or $4, $4, $3
3055; MMELR6-NEXT:    sc $4, 0($6)
3056; MMELR6-NEXT:    beqc $4, $zero, $BB8_1
3057; MMELR6-NEXT:  # %bb.2: # %entry
3058; MMELR6-NEXT:    and $1, $2, $8
3059; MMELR6-NEXT:    srlv $1, $1, $10
3060; MMELR6-NEXT:    seh $1, $1
3061; MMELR6-NEXT:  # %bb.3: # %entry
3062; MMELR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3063; MMELR6-NEXT:  # %bb.4: # %entry
3064; MMELR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
3065; MMELR6-NEXT:    sync
3066; MMELR6-NEXT:    addiu $sp, $sp, 8
3067; MMELR6-NEXT:    jrc $ra
3068;
3069; MIPS64-LABEL: test_max_8:
3070; MIPS64:       # %bb.0: # %entry
3071; MIPS64-NEXT:    daddiu $sp, $sp, -16
3072; MIPS64-NEXT:    .cfi_def_cfa_offset 16
3073; MIPS64-NEXT:    move $1, $5
3074; MIPS64-NEXT:    sync
3075; MIPS64-NEXT:    daddiu $2, $zero, -4
3076; MIPS64-NEXT:    and $6, $4, $2
3077; MIPS64-NEXT:    andi $2, $4, 3
3078; MIPS64-NEXT:    xori $2, $2, 3
3079; MIPS64-NEXT:    sll $10, $2, 3
3080; MIPS64-NEXT:    ori $2, $zero, 255
3081; MIPS64-NEXT:    sllv $8, $2, $10
3082; MIPS64-NEXT:    nor $9, $zero, $8
3083; MIPS64-NEXT:    sllv $7, $1, $10
3084; MIPS64-NEXT:  .LBB8_1: # %entry
3085; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
3086; MIPS64-NEXT:    ll $2, 0($6)
3087; MIPS64-NEXT:    slt $5, $2, $7
3088; MIPS64-NEXT:    move $3, $2
3089; MIPS64-NEXT:    movn $3, $7, $5
3090; MIPS64-NEXT:    and $3, $3, $8
3091; MIPS64-NEXT:    and $4, $2, $9
3092; MIPS64-NEXT:    or $4, $4, $3
3093; MIPS64-NEXT:    sc $4, 0($6)
3094; MIPS64-NEXT:    beqz $4, .LBB8_1
3095; MIPS64-NEXT:    nop
3096; MIPS64-NEXT:  # %bb.2: # %entry
3097; MIPS64-NEXT:    and $1, $2, $8
3098; MIPS64-NEXT:    srlv $1, $1, $10
3099; MIPS64-NEXT:    seh $1, $1
3100; MIPS64-NEXT:  # %bb.3: # %entry
3101; MIPS64-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
3102; MIPS64-NEXT:  # %bb.4: # %entry
3103; MIPS64-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
3104; MIPS64-NEXT:    sync
3105; MIPS64-NEXT:    daddiu $sp, $sp, 16
3106; MIPS64-NEXT:    jr $ra
3107; MIPS64-NEXT:    nop
3108;
3109; MIPS64R6-LABEL: test_max_8:
3110; MIPS64R6:       # %bb.0: # %entry
3111; MIPS64R6-NEXT:    daddiu $sp, $sp, -16
3112; MIPS64R6-NEXT:    .cfi_def_cfa_offset 16
3113; MIPS64R6-NEXT:    move $1, $5
3114; MIPS64R6-NEXT:    sync
3115; MIPS64R6-NEXT:    daddiu $2, $zero, -4
3116; MIPS64R6-NEXT:    and $6, $4, $2
3117; MIPS64R6-NEXT:    andi $2, $4, 3
3118; MIPS64R6-NEXT:    xori $2, $2, 3
3119; MIPS64R6-NEXT:    sll $10, $2, 3
3120; MIPS64R6-NEXT:    ori $2, $zero, 255
3121; MIPS64R6-NEXT:    sllv $8, $2, $10
3122; MIPS64R6-NEXT:    nor $9, $zero, $8
3123; MIPS64R6-NEXT:    sllv $7, $1, $10
3124; MIPS64R6-NEXT:  .LBB8_1: # %entry
3125; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
3126; MIPS64R6-NEXT:    ll $2, 0($6)
3127; MIPS64R6-NEXT:    slt $5, $2, $7
3128; MIPS64R6-NEXT:    seleqz $3, $2, $5
3129; MIPS64R6-NEXT:    selnez $5, $7, $5
3130; MIPS64R6-NEXT:    or $3, $3, $5
3131; MIPS64R6-NEXT:    and $3, $3, $8
3132; MIPS64R6-NEXT:    and $4, $2, $9
3133; MIPS64R6-NEXT:    or $4, $4, $3
3134; MIPS64R6-NEXT:    sc $4, 0($6)
3135; MIPS64R6-NEXT:    beqzc $4, .LBB8_1
3136; MIPS64R6-NEXT:  # %bb.2: # %entry
3137; MIPS64R6-NEXT:    and $1, $2, $8
3138; MIPS64R6-NEXT:    srlv $1, $1, $10
3139; MIPS64R6-NEXT:    seh $1, $1
3140; MIPS64R6-NEXT:  # %bb.3: # %entry
3141; MIPS64R6-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
3142; MIPS64R6-NEXT:  # %bb.4: # %entry
3143; MIPS64R6-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
3144; MIPS64R6-NEXT:    sync
3145; MIPS64R6-NEXT:    daddiu $sp, $sp, 16
3146; MIPS64R6-NEXT:    jrc $ra
3147;
3148; MIPS64EL-LABEL: test_max_8:
3149; MIPS64EL:       # %bb.0: # %entry
3150; MIPS64EL-NEXT:    daddiu $sp, $sp, -16
3151; MIPS64EL-NEXT:    .cfi_def_cfa_offset 16
3152; MIPS64EL-NEXT:    move $1, $5
3153; MIPS64EL-NEXT:    sync
3154; MIPS64EL-NEXT:    daddiu $2, $zero, -4
3155; MIPS64EL-NEXT:    and $6, $4, $2
3156; MIPS64EL-NEXT:    andi $2, $4, 3
3157; MIPS64EL-NEXT:    sll $10, $2, 3
3158; MIPS64EL-NEXT:    ori $2, $zero, 255
3159; MIPS64EL-NEXT:    sllv $8, $2, $10
3160; MIPS64EL-NEXT:    nor $9, $zero, $8
3161; MIPS64EL-NEXT:    sllv $7, $1, $10
3162; MIPS64EL-NEXT:  .LBB8_1: # %entry
3163; MIPS64EL-NEXT:    # =>This Inner Loop Header: Depth=1
3164; MIPS64EL-NEXT:    ll $2, 0($6)
3165; MIPS64EL-NEXT:    and $2, $2, $8
3166; MIPS64EL-NEXT:    and $7, $7, $8
3167; MIPS64EL-NEXT:    slt $5, $2, $7
3168; MIPS64EL-NEXT:    move $3, $2
3169; MIPS64EL-NEXT:    movn $3, $7, $5
3170; MIPS64EL-NEXT:    and $3, $3, $8
3171; MIPS64EL-NEXT:    and $4, $2, $9
3172; MIPS64EL-NEXT:    or $4, $4, $3
3173; MIPS64EL-NEXT:    sc $4, 0($6)
3174; MIPS64EL-NEXT:    beqz $4, .LBB8_1
3175; MIPS64EL-NEXT:    nop
3176; MIPS64EL-NEXT:  # %bb.2: # %entry
3177; MIPS64EL-NEXT:    and $1, $2, $8
3178; MIPS64EL-NEXT:    srlv $1, $1, $10
3179; MIPS64EL-NEXT:    seh $1, $1
3180; MIPS64EL-NEXT:  # %bb.3: # %entry
3181; MIPS64EL-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
3182; MIPS64EL-NEXT:  # %bb.4: # %entry
3183; MIPS64EL-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
3184; MIPS64EL-NEXT:    sync
3185; MIPS64EL-NEXT:    daddiu $sp, $sp, 16
3186; MIPS64EL-NEXT:    jr $ra
3187; MIPS64EL-NEXT:    nop
3188;
3189; MIPS64ELR6-LABEL: test_max_8:
3190; MIPS64ELR6:       # %bb.0: # %entry
3191; MIPS64ELR6-NEXT:    daddiu $sp, $sp, -16
3192; MIPS64ELR6-NEXT:    .cfi_def_cfa_offset 16
3193; MIPS64ELR6-NEXT:    move $1, $5
3194; MIPS64ELR6-NEXT:    sync
3195; MIPS64ELR6-NEXT:    daddiu $2, $zero, -4
3196; MIPS64ELR6-NEXT:    and $6, $4, $2
3197; MIPS64ELR6-NEXT:    andi $2, $4, 3
3198; MIPS64ELR6-NEXT:    sll $10, $2, 3
3199; MIPS64ELR6-NEXT:    ori $2, $zero, 255
3200; MIPS64ELR6-NEXT:    sllv $8, $2, $10
3201; MIPS64ELR6-NEXT:    nor $9, $zero, $8
3202; MIPS64ELR6-NEXT:    sllv $7, $1, $10
3203; MIPS64ELR6-NEXT:  .LBB8_1: # %entry
3204; MIPS64ELR6-NEXT:    # =>This Inner Loop Header: Depth=1
3205; MIPS64ELR6-NEXT:    ll $2, 0($6)
3206; MIPS64ELR6-NEXT:    and $2, $2, $8
3207; MIPS64ELR6-NEXT:    and $7, $7, $8
3208; MIPS64ELR6-NEXT:    slt $5, $2, $7
3209; MIPS64ELR6-NEXT:    seleqz $3, $2, $5
3210; MIPS64ELR6-NEXT:    selnez $5, $7, $5
3211; MIPS64ELR6-NEXT:    or $3, $3, $5
3212; MIPS64ELR6-NEXT:    and $3, $3, $8
3213; MIPS64ELR6-NEXT:    and $4, $2, $9
3214; MIPS64ELR6-NEXT:    or $4, $4, $3
3215; MIPS64ELR6-NEXT:    sc $4, 0($6)
3216; MIPS64ELR6-NEXT:    beqzc $4, .LBB8_1
3217; MIPS64ELR6-NEXT:  # %bb.2: # %entry
3218; MIPS64ELR6-NEXT:    and $1, $2, $8
3219; MIPS64ELR6-NEXT:    srlv $1, $1, $10
3220; MIPS64ELR6-NEXT:    seh $1, $1
3221; MIPS64ELR6-NEXT:  # %bb.3: # %entry
3222; MIPS64ELR6-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
3223; MIPS64ELR6-NEXT:  # %bb.4: # %entry
3224; MIPS64ELR6-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
3225; MIPS64ELR6-NEXT:    sync
3226; MIPS64ELR6-NEXT:    daddiu $sp, $sp, 16
3227; MIPS64ELR6-NEXT:    jrc $ra
3228entry:
3229  %0 = atomicrmw max i8* %ptr, i8 %val seq_cst
3230  ret i8 %0
3231}
3232
3233define i8 @test_min_8(i8* nocapture %ptr, i8 signext %val) {
3234; MIPS-LABEL: test_min_8:
3235; MIPS:       # %bb.0: # %entry
3236; MIPS-NEXT:    addiu $sp, $sp, -8
3237; MIPS-NEXT:    .cfi_def_cfa_offset 8
3238; MIPS-NEXT:    # kill: def $at killed $a1
3239; MIPS-NEXT:    sync
3240; MIPS-NEXT:    addiu $1, $zero, -4
3241; MIPS-NEXT:    and $6, $4, $1
3242; MIPS-NEXT:    andi $1, $4, 3
3243; MIPS-NEXT:    xori $1, $1, 3
3244; MIPS-NEXT:    sll $10, $1, 3
3245; MIPS-NEXT:    ori $1, $zero, 255
3246; MIPS-NEXT:    sllv $8, $1, $10
3247; MIPS-NEXT:    nor $9, $zero, $8
3248; MIPS-NEXT:    sllv $7, $5, $10
3249; MIPS-NEXT:  $BB9_1: # %entry
3250; MIPS-NEXT:    # =>This Inner Loop Header: Depth=1
3251; MIPS-NEXT:    ll $2, 0($6)
3252; MIPS-NEXT:    slt $5, $2, $7
3253; MIPS-NEXT:    move $3, $2
3254; MIPS-NEXT:    movz $3, $7, $5
3255; MIPS-NEXT:    and $3, $3, $8
3256; MIPS-NEXT:    and $4, $2, $9
3257; MIPS-NEXT:    or $4, $4, $3
3258; MIPS-NEXT:    sc $4, 0($6)
3259; MIPS-NEXT:    beqz $4, $BB9_1
3260; MIPS-NEXT:    nop
3261; MIPS-NEXT:  # %bb.2: # %entry
3262; MIPS-NEXT:    and $1, $2, $8
3263; MIPS-NEXT:    srlv $1, $1, $10
3264; MIPS-NEXT:    seh $1, $1
3265; MIPS-NEXT:  # %bb.3: # %entry
3266; MIPS-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3267; MIPS-NEXT:  # %bb.4: # %entry
3268; MIPS-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
3269; MIPS-NEXT:    sync
3270; MIPS-NEXT:    addiu $sp, $sp, 8
3271; MIPS-NEXT:    jr $ra
3272; MIPS-NEXT:    nop
3273;
3274; MIPSR6-LABEL: test_min_8:
3275; MIPSR6:       # %bb.0: # %entry
3276; MIPSR6-NEXT:    addiu $sp, $sp, -8
3277; MIPSR6-NEXT:    .cfi_def_cfa_offset 8
3278; MIPSR6-NEXT:    # kill: def $at killed $a1
3279; MIPSR6-NEXT:    sync
3280; MIPSR6-NEXT:    addiu $1, $zero, -4
3281; MIPSR6-NEXT:    and $6, $4, $1
3282; MIPSR6-NEXT:    andi $1, $4, 3
3283; MIPSR6-NEXT:    xori $1, $1, 3
3284; MIPSR6-NEXT:    sll $10, $1, 3
3285; MIPSR6-NEXT:    ori $1, $zero, 255
3286; MIPSR6-NEXT:    sllv $8, $1, $10
3287; MIPSR6-NEXT:    nor $9, $zero, $8
3288; MIPSR6-NEXT:    sllv $7, $5, $10
3289; MIPSR6-NEXT:  $BB9_1: # %entry
3290; MIPSR6-NEXT:    # =>This Inner Loop Header: Depth=1
3291; MIPSR6-NEXT:    ll $2, 0($6)
3292; MIPSR6-NEXT:    slt $5, $2, $7
3293; MIPSR6-NEXT:    selnez $3, $2, $5
3294; MIPSR6-NEXT:    seleqz $5, $7, $5
3295; MIPSR6-NEXT:    or $3, $3, $5
3296; MIPSR6-NEXT:    and $3, $3, $8
3297; MIPSR6-NEXT:    and $4, $2, $9
3298; MIPSR6-NEXT:    or $4, $4, $3
3299; MIPSR6-NEXT:    sc $4, 0($6)
3300; MIPSR6-NEXT:    beqzc $4, $BB9_1
3301; MIPSR6-NEXT:  # %bb.2: # %entry
3302; MIPSR6-NEXT:    and $1, $2, $8
3303; MIPSR6-NEXT:    srlv $1, $1, $10
3304; MIPSR6-NEXT:    seh $1, $1
3305; MIPSR6-NEXT:  # %bb.3: # %entry
3306; MIPSR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3307; MIPSR6-NEXT:  # %bb.4: # %entry
3308; MIPSR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
3309; MIPSR6-NEXT:    sync
3310; MIPSR6-NEXT:    addiu $sp, $sp, 8
3311; MIPSR6-NEXT:    jrc $ra
3312;
3313; MM-LABEL: test_min_8:
3314; MM:       # %bb.0: # %entry
3315; MM-NEXT:    addiu $sp, $sp, -8
3316; MM-NEXT:    .cfi_def_cfa_offset 8
3317; MM-NEXT:    # kill: def $at killed $a1
3318; MM-NEXT:    sync
3319; MM-NEXT:    addiu $1, $zero, -4
3320; MM-NEXT:    and $6, $4, $1
3321; MM-NEXT:    andi $1, $4, 3
3322; MM-NEXT:    xori $1, $1, 3
3323; MM-NEXT:    sll $10, $1, 3
3324; MM-NEXT:    ori $1, $zero, 255
3325; MM-NEXT:    sllv $8, $1, $10
3326; MM-NEXT:    nor $9, $zero, $8
3327; MM-NEXT:    sllv $7, $5, $10
3328; MM-NEXT:  $BB9_1: # %entry
3329; MM-NEXT:    # =>This Inner Loop Header: Depth=1
3330; MM-NEXT:    ll $2, 0($6)
3331; MM-NEXT:    slt $5, $2, $7
3332; MM-NEXT:    or $3, $2, $zero
3333; MM-NEXT:    movz $3, $7, $5
3334; MM-NEXT:    and $3, $3, $8
3335; MM-NEXT:    and $4, $2, $9
3336; MM-NEXT:    or $4, $4, $3
3337; MM-NEXT:    sc $4, 0($6)
3338; MM-NEXT:    beqzc $4, $BB9_1
3339; MM-NEXT:  # %bb.2: # %entry
3340; MM-NEXT:    and $1, $2, $8
3341; MM-NEXT:    srlv $1, $1, $10
3342; MM-NEXT:    seh $1, $1
3343; MM-NEXT:  # %bb.3: # %entry
3344; MM-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3345; MM-NEXT:  # %bb.4: # %entry
3346; MM-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
3347; MM-NEXT:    sync
3348; MM-NEXT:    addiusp 8
3349; MM-NEXT:    jrc $ra
3350;
3351; MMR6-LABEL: test_min_8:
3352; MMR6:       # %bb.0: # %entry
3353; MMR6-NEXT:    addiu $sp, $sp, -8
3354; MMR6-NEXT:    .cfi_def_cfa_offset 8
3355; MMR6-NEXT:    # kill: def $at killed $a1
3356; MMR6-NEXT:    sync
3357; MMR6-NEXT:    addiu $1, $zero, -4
3358; MMR6-NEXT:    and $6, $4, $1
3359; MMR6-NEXT:    andi $1, $4, 3
3360; MMR6-NEXT:    xori $1, $1, 3
3361; MMR6-NEXT:    sll $10, $1, 3
3362; MMR6-NEXT:    ori $1, $zero, 255
3363; MMR6-NEXT:    sllv $8, $1, $10
3364; MMR6-NEXT:    nor $9, $zero, $8
3365; MMR6-NEXT:    sllv $7, $5, $10
3366; MMR6-NEXT:  $BB9_1: # %entry
3367; MMR6-NEXT:    # =>This Inner Loop Header: Depth=1
3368; MMR6-NEXT:    ll $2, 0($6)
3369; MMR6-NEXT:    slt $5, $2, $7
3370; MMR6-NEXT:    selnez $3, $2, $5
3371; MMR6-NEXT:    seleqz $5, $7, $5
3372; MMR6-NEXT:    or $3, $3, $5
3373; MMR6-NEXT:    and $3, $3, $8
3374; MMR6-NEXT:    and $4, $2, $9
3375; MMR6-NEXT:    or $4, $4, $3
3376; MMR6-NEXT:    sc $4, 0($6)
3377; MMR6-NEXT:    beqc $4, $zero, $BB9_1
3378; MMR6-NEXT:  # %bb.2: # %entry
3379; MMR6-NEXT:    and $1, $2, $8
3380; MMR6-NEXT:    srlv $1, $1, $10
3381; MMR6-NEXT:    seh $1, $1
3382; MMR6-NEXT:  # %bb.3: # %entry
3383; MMR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3384; MMR6-NEXT:  # %bb.4: # %entry
3385; MMR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
3386; MMR6-NEXT:    sync
3387; MMR6-NEXT:    addiu $sp, $sp, 8
3388; MMR6-NEXT:    jrc $ra
3389;
3390; MIPSEL-LABEL: test_min_8:
3391; MIPSEL:       # %bb.0: # %entry
3392; MIPSEL-NEXT:    addiu $sp, $sp, -8
3393; MIPSEL-NEXT:    .cfi_def_cfa_offset 8
3394; MIPSEL-NEXT:    # kill: def $at killed $a1
3395; MIPSEL-NEXT:    sync
3396; MIPSEL-NEXT:    addiu $1, $zero, -4
3397; MIPSEL-NEXT:    and $6, $4, $1
3398; MIPSEL-NEXT:    andi $1, $4, 3
3399; MIPSEL-NEXT:    sll $10, $1, 3
3400; MIPSEL-NEXT:    ori $1, $zero, 255
3401; MIPSEL-NEXT:    sllv $8, $1, $10
3402; MIPSEL-NEXT:    nor $9, $zero, $8
3403; MIPSEL-NEXT:    sllv $7, $5, $10
3404; MIPSEL-NEXT:  $BB9_1: # %entry
3405; MIPSEL-NEXT:    # =>This Inner Loop Header: Depth=1
3406; MIPSEL-NEXT:    ll $2, 0($6)
3407; MIPSEL-NEXT:    and $2, $2, $8
3408; MIPSEL-NEXT:    and $7, $7, $8
3409; MIPSEL-NEXT:    slt $5, $2, $7
3410; MIPSEL-NEXT:    move $3, $2
3411; MIPSEL-NEXT:    movz $3, $7, $5
3412; MIPSEL-NEXT:    and $3, $3, $8
3413; MIPSEL-NEXT:    and $4, $2, $9
3414; MIPSEL-NEXT:    or $4, $4, $3
3415; MIPSEL-NEXT:    sc $4, 0($6)
3416; MIPSEL-NEXT:    beqz $4, $BB9_1
3417; MIPSEL-NEXT:    nop
3418; MIPSEL-NEXT:  # %bb.2: # %entry
3419; MIPSEL-NEXT:    and $1, $2, $8
3420; MIPSEL-NEXT:    srlv $1, $1, $10
3421; MIPSEL-NEXT:    seh $1, $1
3422; MIPSEL-NEXT:  # %bb.3: # %entry
3423; MIPSEL-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3424; MIPSEL-NEXT:  # %bb.4: # %entry
3425; MIPSEL-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
3426; MIPSEL-NEXT:    sync
3427; MIPSEL-NEXT:    addiu $sp, $sp, 8
3428; MIPSEL-NEXT:    jr $ra
3429; MIPSEL-NEXT:    nop
3430;
3431; MIPSELR6-LABEL: test_min_8:
3432; MIPSELR6:       # %bb.0: # %entry
3433; MIPSELR6-NEXT:    addiu $sp, $sp, -8
3434; MIPSELR6-NEXT:    .cfi_def_cfa_offset 8
3435; MIPSELR6-NEXT:    # kill: def $at killed $a1
3436; MIPSELR6-NEXT:    sync
3437; MIPSELR6-NEXT:    addiu $1, $zero, -4
3438; MIPSELR6-NEXT:    and $6, $4, $1
3439; MIPSELR6-NEXT:    andi $1, $4, 3
3440; MIPSELR6-NEXT:    sll $10, $1, 3
3441; MIPSELR6-NEXT:    ori $1, $zero, 255
3442; MIPSELR6-NEXT:    sllv $8, $1, $10
3443; MIPSELR6-NEXT:    nor $9, $zero, $8
3444; MIPSELR6-NEXT:    sllv $7, $5, $10
3445; MIPSELR6-NEXT:  $BB9_1: # %entry
3446; MIPSELR6-NEXT:    # =>This Inner Loop Header: Depth=1
3447; MIPSELR6-NEXT:    ll $2, 0($6)
3448; MIPSELR6-NEXT:    and $2, $2, $8
3449; MIPSELR6-NEXT:    and $7, $7, $8
3450; MIPSELR6-NEXT:    slt $5, $2, $7
3451; MIPSELR6-NEXT:    selnez $3, $2, $5
3452; MIPSELR6-NEXT:    seleqz $5, $7, $5
3453; MIPSELR6-NEXT:    or $3, $3, $5
3454; MIPSELR6-NEXT:    and $3, $3, $8
3455; MIPSELR6-NEXT:    and $4, $2, $9
3456; MIPSELR6-NEXT:    or $4, $4, $3
3457; MIPSELR6-NEXT:    sc $4, 0($6)
3458; MIPSELR6-NEXT:    beqzc $4, $BB9_1
3459; MIPSELR6-NEXT:  # %bb.2: # %entry
3460; MIPSELR6-NEXT:    and $1, $2, $8
3461; MIPSELR6-NEXT:    srlv $1, $1, $10
3462; MIPSELR6-NEXT:    seh $1, $1
3463; MIPSELR6-NEXT:  # %bb.3: # %entry
3464; MIPSELR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3465; MIPSELR6-NEXT:  # %bb.4: # %entry
3466; MIPSELR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
3467; MIPSELR6-NEXT:    sync
3468; MIPSELR6-NEXT:    addiu $sp, $sp, 8
3469; MIPSELR6-NEXT:    jrc $ra
3470;
3471; MMEL-LABEL: test_min_8:
3472; MMEL:       # %bb.0: # %entry
3473; MMEL-NEXT:    addiu $sp, $sp, -8
3474; MMEL-NEXT:    .cfi_def_cfa_offset 8
3475; MMEL-NEXT:    # kill: def $at killed $a1
3476; MMEL-NEXT:    sync
3477; MMEL-NEXT:    addiu $1, $zero, -4
3478; MMEL-NEXT:    and $6, $4, $1
3479; MMEL-NEXT:    andi $1, $4, 3
3480; MMEL-NEXT:    sll $10, $1, 3
3481; MMEL-NEXT:    ori $1, $zero, 255
3482; MMEL-NEXT:    sllv $8, $1, $10
3483; MMEL-NEXT:    nor $9, $zero, $8
3484; MMEL-NEXT:    sllv $7, $5, $10
3485; MMEL-NEXT:  $BB9_1: # %entry
3486; MMEL-NEXT:    # =>This Inner Loop Header: Depth=1
3487; MMEL-NEXT:    ll $2, 0($6)
3488; MMEL-NEXT:    and $2, $2, $8
3489; MMEL-NEXT:    and $7, $7, $8
3490; MMEL-NEXT:    slt $5, $2, $7
3491; MMEL-NEXT:    or $3, $2, $zero
3492; MMEL-NEXT:    movz $3, $7, $5
3493; MMEL-NEXT:    and $3, $3, $8
3494; MMEL-NEXT:    and $4, $2, $9
3495; MMEL-NEXT:    or $4, $4, $3
3496; MMEL-NEXT:    sc $4, 0($6)
3497; MMEL-NEXT:    beqzc $4, $BB9_1
3498; MMEL-NEXT:  # %bb.2: # %entry
3499; MMEL-NEXT:    and $1, $2, $8
3500; MMEL-NEXT:    srlv $1, $1, $10
3501; MMEL-NEXT:    seh $1, $1
3502; MMEL-NEXT:  # %bb.3: # %entry
3503; MMEL-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3504; MMEL-NEXT:  # %bb.4: # %entry
3505; MMEL-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
3506; MMEL-NEXT:    sync
3507; MMEL-NEXT:    addiusp 8
3508; MMEL-NEXT:    jrc $ra
3509;
3510; MMELR6-LABEL: test_min_8:
3511; MMELR6:       # %bb.0: # %entry
3512; MMELR6-NEXT:    addiu $sp, $sp, -8
3513; MMELR6-NEXT:    .cfi_def_cfa_offset 8
3514; MMELR6-NEXT:    # kill: def $at killed $a1
3515; MMELR6-NEXT:    sync
3516; MMELR6-NEXT:    addiu $1, $zero, -4
3517; MMELR6-NEXT:    and $6, $4, $1
3518; MMELR6-NEXT:    andi $1, $4, 3
3519; MMELR6-NEXT:    sll $10, $1, 3
3520; MMELR6-NEXT:    ori $1, $zero, 255
3521; MMELR6-NEXT:    sllv $8, $1, $10
3522; MMELR6-NEXT:    nor $9, $zero, $8
3523; MMELR6-NEXT:    sllv $7, $5, $10
3524; MMELR6-NEXT:  $BB9_1: # %entry
3525; MMELR6-NEXT:    # =>This Inner Loop Header: Depth=1
3526; MMELR6-NEXT:    ll $2, 0($6)
3527; MMELR6-NEXT:    and $2, $2, $8
3528; MMELR6-NEXT:    and $7, $7, $8
3529; MMELR6-NEXT:    slt $5, $2, $7
3530; MMELR6-NEXT:    selnez $3, $2, $5
3531; MMELR6-NEXT:    seleqz $5, $7, $5
3532; MMELR6-NEXT:    or $3, $3, $5
3533; MMELR6-NEXT:    and $3, $3, $8
3534; MMELR6-NEXT:    and $4, $2, $9
3535; MMELR6-NEXT:    or $4, $4, $3
3536; MMELR6-NEXT:    sc $4, 0($6)
3537; MMELR6-NEXT:    beqc $4, $zero, $BB9_1
3538; MMELR6-NEXT:  # %bb.2: # %entry
3539; MMELR6-NEXT:    and $1, $2, $8
3540; MMELR6-NEXT:    srlv $1, $1, $10
3541; MMELR6-NEXT:    seh $1, $1
3542; MMELR6-NEXT:  # %bb.3: # %entry
3543; MMELR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3544; MMELR6-NEXT:  # %bb.4: # %entry
3545; MMELR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
3546; MMELR6-NEXT:    sync
3547; MMELR6-NEXT:    addiu $sp, $sp, 8
3548; MMELR6-NEXT:    jrc $ra
3549;
3550; MIPS64-LABEL: test_min_8:
3551; MIPS64:       # %bb.0: # %entry
3552; MIPS64-NEXT:    daddiu $sp, $sp, -16
3553; MIPS64-NEXT:    .cfi_def_cfa_offset 16
3554; MIPS64-NEXT:    move $1, $5
3555; MIPS64-NEXT:    sync
3556; MIPS64-NEXT:    daddiu $2, $zero, -4
3557; MIPS64-NEXT:    and $6, $4, $2
3558; MIPS64-NEXT:    andi $2, $4, 3
3559; MIPS64-NEXT:    xori $2, $2, 3
3560; MIPS64-NEXT:    sll $10, $2, 3
3561; MIPS64-NEXT:    ori $2, $zero, 255
3562; MIPS64-NEXT:    sllv $8, $2, $10
3563; MIPS64-NEXT:    nor $9, $zero, $8
3564; MIPS64-NEXT:    sllv $7, $1, $10
3565; MIPS64-NEXT:  .LBB9_1: # %entry
3566; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
3567; MIPS64-NEXT:    ll $2, 0($6)
3568; MIPS64-NEXT:    slt $5, $2, $7
3569; MIPS64-NEXT:    move $3, $2
3570; MIPS64-NEXT:    movz $3, $7, $5
3571; MIPS64-NEXT:    and $3, $3, $8
3572; MIPS64-NEXT:    and $4, $2, $9
3573; MIPS64-NEXT:    or $4, $4, $3
3574; MIPS64-NEXT:    sc $4, 0($6)
3575; MIPS64-NEXT:    beqz $4, .LBB9_1
3576; MIPS64-NEXT:    nop
3577; MIPS64-NEXT:  # %bb.2: # %entry
3578; MIPS64-NEXT:    and $1, $2, $8
3579; MIPS64-NEXT:    srlv $1, $1, $10
3580; MIPS64-NEXT:    seh $1, $1
3581; MIPS64-NEXT:  # %bb.3: # %entry
3582; MIPS64-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
3583; MIPS64-NEXT:  # %bb.4: # %entry
3584; MIPS64-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
3585; MIPS64-NEXT:    sync
3586; MIPS64-NEXT:    daddiu $sp, $sp, 16
3587; MIPS64-NEXT:    jr $ra
3588; MIPS64-NEXT:    nop
3589;
3590; MIPS64R6-LABEL: test_min_8:
3591; MIPS64R6:       # %bb.0: # %entry
3592; MIPS64R6-NEXT:    daddiu $sp, $sp, -16
3593; MIPS64R6-NEXT:    .cfi_def_cfa_offset 16
3594; MIPS64R6-NEXT:    move $1, $5
3595; MIPS64R6-NEXT:    sync
3596; MIPS64R6-NEXT:    daddiu $2, $zero, -4
3597; MIPS64R6-NEXT:    and $6, $4, $2
3598; MIPS64R6-NEXT:    andi $2, $4, 3
3599; MIPS64R6-NEXT:    xori $2, $2, 3
3600; MIPS64R6-NEXT:    sll $10, $2, 3
3601; MIPS64R6-NEXT:    ori $2, $zero, 255
3602; MIPS64R6-NEXT:    sllv $8, $2, $10
3603; MIPS64R6-NEXT:    nor $9, $zero, $8
3604; MIPS64R6-NEXT:    sllv $7, $1, $10
3605; MIPS64R6-NEXT:  .LBB9_1: # %entry
3606; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
3607; MIPS64R6-NEXT:    ll $2, 0($6)
3608; MIPS64R6-NEXT:    slt $5, $2, $7
3609; MIPS64R6-NEXT:    selnez $3, $2, $5
3610; MIPS64R6-NEXT:    seleqz $5, $7, $5
3611; MIPS64R6-NEXT:    or $3, $3, $5
3612; MIPS64R6-NEXT:    and $3, $3, $8
3613; MIPS64R6-NEXT:    and $4, $2, $9
3614; MIPS64R6-NEXT:    or $4, $4, $3
3615; MIPS64R6-NEXT:    sc $4, 0($6)
3616; MIPS64R6-NEXT:    beqzc $4, .LBB9_1
3617; MIPS64R6-NEXT:  # %bb.2: # %entry
3618; MIPS64R6-NEXT:    and $1, $2, $8
3619; MIPS64R6-NEXT:    srlv $1, $1, $10
3620; MIPS64R6-NEXT:    seh $1, $1
3621; MIPS64R6-NEXT:  # %bb.3: # %entry
3622; MIPS64R6-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
3623; MIPS64R6-NEXT:  # %bb.4: # %entry
3624; MIPS64R6-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
3625; MIPS64R6-NEXT:    sync
3626; MIPS64R6-NEXT:    daddiu $sp, $sp, 16
3627; MIPS64R6-NEXT:    jrc $ra
3628;
3629; MIPS64EL-LABEL: test_min_8:
3630; MIPS64EL:       # %bb.0: # %entry
3631; MIPS64EL-NEXT:    daddiu $sp, $sp, -16
3632; MIPS64EL-NEXT:    .cfi_def_cfa_offset 16
3633; MIPS64EL-NEXT:    move $1, $5
3634; MIPS64EL-NEXT:    sync
3635; MIPS64EL-NEXT:    daddiu $2, $zero, -4
3636; MIPS64EL-NEXT:    and $6, $4, $2
3637; MIPS64EL-NEXT:    andi $2, $4, 3
3638; MIPS64EL-NEXT:    sll $10, $2, 3
3639; MIPS64EL-NEXT:    ori $2, $zero, 255
3640; MIPS64EL-NEXT:    sllv $8, $2, $10
3641; MIPS64EL-NEXT:    nor $9, $zero, $8
3642; MIPS64EL-NEXT:    sllv $7, $1, $10
3643; MIPS64EL-NEXT:  .LBB9_1: # %entry
3644; MIPS64EL-NEXT:    # =>This Inner Loop Header: Depth=1
3645; MIPS64EL-NEXT:    ll $2, 0($6)
3646; MIPS64EL-NEXT:    and $2, $2, $8
3647; MIPS64EL-NEXT:    and $7, $7, $8
3648; MIPS64EL-NEXT:    slt $5, $2, $7
3649; MIPS64EL-NEXT:    move $3, $2
3650; MIPS64EL-NEXT:    movz $3, $7, $5
3651; MIPS64EL-NEXT:    and $3, $3, $8
3652; MIPS64EL-NEXT:    and $4, $2, $9
3653; MIPS64EL-NEXT:    or $4, $4, $3
3654; MIPS64EL-NEXT:    sc $4, 0($6)
3655; MIPS64EL-NEXT:    beqz $4, .LBB9_1
3656; MIPS64EL-NEXT:    nop
3657; MIPS64EL-NEXT:  # %bb.2: # %entry
3658; MIPS64EL-NEXT:    and $1, $2, $8
3659; MIPS64EL-NEXT:    srlv $1, $1, $10
3660; MIPS64EL-NEXT:    seh $1, $1
3661; MIPS64EL-NEXT:  # %bb.3: # %entry
3662; MIPS64EL-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
3663; MIPS64EL-NEXT:  # %bb.4: # %entry
3664; MIPS64EL-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
3665; MIPS64EL-NEXT:    sync
3666; MIPS64EL-NEXT:    daddiu $sp, $sp, 16
3667; MIPS64EL-NEXT:    jr $ra
3668; MIPS64EL-NEXT:    nop
3669;
3670; MIPS64ELR6-LABEL: test_min_8:
3671; MIPS64ELR6:       # %bb.0: # %entry
3672; MIPS64ELR6-NEXT:    daddiu $sp, $sp, -16
3673; MIPS64ELR6-NEXT:    .cfi_def_cfa_offset 16
3674; MIPS64ELR6-NEXT:    move $1, $5
3675; MIPS64ELR6-NEXT:    sync
3676; MIPS64ELR6-NEXT:    daddiu $2, $zero, -4
3677; MIPS64ELR6-NEXT:    and $6, $4, $2
3678; MIPS64ELR6-NEXT:    andi $2, $4, 3
3679; MIPS64ELR6-NEXT:    sll $10, $2, 3
3680; MIPS64ELR6-NEXT:    ori $2, $zero, 255
3681; MIPS64ELR6-NEXT:    sllv $8, $2, $10
3682; MIPS64ELR6-NEXT:    nor $9, $zero, $8
3683; MIPS64ELR6-NEXT:    sllv $7, $1, $10
3684; MIPS64ELR6-NEXT:  .LBB9_1: # %entry
3685; MIPS64ELR6-NEXT:    # =>This Inner Loop Header: Depth=1
3686; MIPS64ELR6-NEXT:    ll $2, 0($6)
3687; MIPS64ELR6-NEXT:    and $2, $2, $8
3688; MIPS64ELR6-NEXT:    and $7, $7, $8
3689; MIPS64ELR6-NEXT:    slt $5, $2, $7
3690; MIPS64ELR6-NEXT:    selnez $3, $2, $5
3691; MIPS64ELR6-NEXT:    seleqz $5, $7, $5
3692; MIPS64ELR6-NEXT:    or $3, $3, $5
3693; MIPS64ELR6-NEXT:    and $3, $3, $8
3694; MIPS64ELR6-NEXT:    and $4, $2, $9
3695; MIPS64ELR6-NEXT:    or $4, $4, $3
3696; MIPS64ELR6-NEXT:    sc $4, 0($6)
3697; MIPS64ELR6-NEXT:    beqzc $4, .LBB9_1
3698; MIPS64ELR6-NEXT:  # %bb.2: # %entry
3699; MIPS64ELR6-NEXT:    and $1, $2, $8
3700; MIPS64ELR6-NEXT:    srlv $1, $1, $10
3701; MIPS64ELR6-NEXT:    seh $1, $1
3702; MIPS64ELR6-NEXT:  # %bb.3: # %entry
3703; MIPS64ELR6-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
3704; MIPS64ELR6-NEXT:  # %bb.4: # %entry
3705; MIPS64ELR6-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
3706; MIPS64ELR6-NEXT:    sync
3707; MIPS64ELR6-NEXT:    daddiu $sp, $sp, 16
3708; MIPS64ELR6-NEXT:    jrc $ra
3709entry:
3710  %0 = atomicrmw min i8* %ptr, i8 %val seq_cst
3711  ret i8 %0
3712}
3713
3714define i8 @test_umax_8(i8* nocapture %ptr, i8 signext %val) {
3715; MIPS-LABEL: test_umax_8:
3716; MIPS:       # %bb.0: # %entry
3717; MIPS-NEXT:    addiu $sp, $sp, -8
3718; MIPS-NEXT:    .cfi_def_cfa_offset 8
3719; MIPS-NEXT:    # kill: def $at killed $a1
3720; MIPS-NEXT:    sync
3721; MIPS-NEXT:    addiu $1, $zero, -4
3722; MIPS-NEXT:    and $6, $4, $1
3723; MIPS-NEXT:    andi $1, $4, 3
3724; MIPS-NEXT:    xori $1, $1, 3
3725; MIPS-NEXT:    sll $10, $1, 3
3726; MIPS-NEXT:    ori $1, $zero, 255
3727; MIPS-NEXT:    sllv $8, $1, $10
3728; MIPS-NEXT:    nor $9, $zero, $8
3729; MIPS-NEXT:    sllv $7, $5, $10
3730; MIPS-NEXT:  $BB10_1: # %entry
3731; MIPS-NEXT:    # =>This Inner Loop Header: Depth=1
3732; MIPS-NEXT:    ll $2, 0($6)
3733; MIPS-NEXT:    sltu $5, $2, $7
3734; MIPS-NEXT:    move $3, $2
3735; MIPS-NEXT:    movn $3, $7, $5
3736; MIPS-NEXT:    and $3, $3, $8
3737; MIPS-NEXT:    and $4, $2, $9
3738; MIPS-NEXT:    or $4, $4, $3
3739; MIPS-NEXT:    sc $4, 0($6)
3740; MIPS-NEXT:    beqz $4, $BB10_1
3741; MIPS-NEXT:    nop
3742; MIPS-NEXT:  # %bb.2: # %entry
3743; MIPS-NEXT:    and $1, $2, $8
3744; MIPS-NEXT:    srlv $1, $1, $10
3745; MIPS-NEXT:    seh $1, $1
3746; MIPS-NEXT:  # %bb.3: # %entry
3747; MIPS-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3748; MIPS-NEXT:  # %bb.4: # %entry
3749; MIPS-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
3750; MIPS-NEXT:    sync
3751; MIPS-NEXT:    addiu $sp, $sp, 8
3752; MIPS-NEXT:    jr $ra
3753; MIPS-NEXT:    nop
3754;
3755; MIPSR6-LABEL: test_umax_8:
3756; MIPSR6:       # %bb.0: # %entry
3757; MIPSR6-NEXT:    addiu $sp, $sp, -8
3758; MIPSR6-NEXT:    .cfi_def_cfa_offset 8
3759; MIPSR6-NEXT:    # kill: def $at killed $a1
3760; MIPSR6-NEXT:    sync
3761; MIPSR6-NEXT:    addiu $1, $zero, -4
3762; MIPSR6-NEXT:    and $6, $4, $1
3763; MIPSR6-NEXT:    andi $1, $4, 3
3764; MIPSR6-NEXT:    xori $1, $1, 3
3765; MIPSR6-NEXT:    sll $10, $1, 3
3766; MIPSR6-NEXT:    ori $1, $zero, 255
3767; MIPSR6-NEXT:    sllv $8, $1, $10
3768; MIPSR6-NEXT:    nor $9, $zero, $8
3769; MIPSR6-NEXT:    sllv $7, $5, $10
3770; MIPSR6-NEXT:  $BB10_1: # %entry
3771; MIPSR6-NEXT:    # =>This Inner Loop Header: Depth=1
3772; MIPSR6-NEXT:    ll $2, 0($6)
3773; MIPSR6-NEXT:    sltu $5, $2, $7
3774; MIPSR6-NEXT:    seleqz $3, $2, $5
3775; MIPSR6-NEXT:    selnez $5, $7, $5
3776; MIPSR6-NEXT:    or $3, $3, $5
3777; MIPSR6-NEXT:    and $3, $3, $8
3778; MIPSR6-NEXT:    and $4, $2, $9
3779; MIPSR6-NEXT:    or $4, $4, $3
3780; MIPSR6-NEXT:    sc $4, 0($6)
3781; MIPSR6-NEXT:    beqzc $4, $BB10_1
3782; MIPSR6-NEXT:  # %bb.2: # %entry
3783; MIPSR6-NEXT:    and $1, $2, $8
3784; MIPSR6-NEXT:    srlv $1, $1, $10
3785; MIPSR6-NEXT:    seh $1, $1
3786; MIPSR6-NEXT:  # %bb.3: # %entry
3787; MIPSR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3788; MIPSR6-NEXT:  # %bb.4: # %entry
3789; MIPSR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
3790; MIPSR6-NEXT:    sync
3791; MIPSR6-NEXT:    addiu $sp, $sp, 8
3792; MIPSR6-NEXT:    jrc $ra
3793;
3794; MM-LABEL: test_umax_8:
3795; MM:       # %bb.0: # %entry
3796; MM-NEXT:    addiu $sp, $sp, -8
3797; MM-NEXT:    .cfi_def_cfa_offset 8
3798; MM-NEXT:    # kill: def $at killed $a1
3799; MM-NEXT:    sync
3800; MM-NEXT:    addiu $1, $zero, -4
3801; MM-NEXT:    and $6, $4, $1
3802; MM-NEXT:    andi $1, $4, 3
3803; MM-NEXT:    xori $1, $1, 3
3804; MM-NEXT:    sll $10, $1, 3
3805; MM-NEXT:    ori $1, $zero, 255
3806; MM-NEXT:    sllv $8, $1, $10
3807; MM-NEXT:    nor $9, $zero, $8
3808; MM-NEXT:    sllv $7, $5, $10
3809; MM-NEXT:  $BB10_1: # %entry
3810; MM-NEXT:    # =>This Inner Loop Header: Depth=1
3811; MM-NEXT:    ll $2, 0($6)
3812; MM-NEXT:    sltu $5, $2, $7
3813; MM-NEXT:    or $3, $2, $zero
3814; MM-NEXT:    movn $3, $7, $5
3815; MM-NEXT:    and $3, $3, $8
3816; MM-NEXT:    and $4, $2, $9
3817; MM-NEXT:    or $4, $4, $3
3818; MM-NEXT:    sc $4, 0($6)
3819; MM-NEXT:    beqzc $4, $BB10_1
3820; MM-NEXT:  # %bb.2: # %entry
3821; MM-NEXT:    and $1, $2, $8
3822; MM-NEXT:    srlv $1, $1, $10
3823; MM-NEXT:    seh $1, $1
3824; MM-NEXT:  # %bb.3: # %entry
3825; MM-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3826; MM-NEXT:  # %bb.4: # %entry
3827; MM-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
3828; MM-NEXT:    sync
3829; MM-NEXT:    addiusp 8
3830; MM-NEXT:    jrc $ra
3831;
3832; MMR6-LABEL: test_umax_8:
3833; MMR6:       # %bb.0: # %entry
3834; MMR6-NEXT:    addiu $sp, $sp, -8
3835; MMR6-NEXT:    .cfi_def_cfa_offset 8
3836; MMR6-NEXT:    # kill: def $at killed $a1
3837; MMR6-NEXT:    sync
3838; MMR6-NEXT:    addiu $1, $zero, -4
3839; MMR6-NEXT:    and $6, $4, $1
3840; MMR6-NEXT:    andi $1, $4, 3
3841; MMR6-NEXT:    xori $1, $1, 3
3842; MMR6-NEXT:    sll $10, $1, 3
3843; MMR6-NEXT:    ori $1, $zero, 255
3844; MMR6-NEXT:    sllv $8, $1, $10
3845; MMR6-NEXT:    nor $9, $zero, $8
3846; MMR6-NEXT:    sllv $7, $5, $10
3847; MMR6-NEXT:  $BB10_1: # %entry
3848; MMR6-NEXT:    # =>This Inner Loop Header: Depth=1
3849; MMR6-NEXT:    ll $2, 0($6)
3850; MMR6-NEXT:    sltu $5, $2, $7
3851; MMR6-NEXT:    seleqz $3, $2, $5
3852; MMR6-NEXT:    selnez $5, $7, $5
3853; MMR6-NEXT:    or $3, $3, $5
3854; MMR6-NEXT:    and $3, $3, $8
3855; MMR6-NEXT:    and $4, $2, $9
3856; MMR6-NEXT:    or $4, $4, $3
3857; MMR6-NEXT:    sc $4, 0($6)
3858; MMR6-NEXT:    beqc $4, $zero, $BB10_1
3859; MMR6-NEXT:  # %bb.2: # %entry
3860; MMR6-NEXT:    and $1, $2, $8
3861; MMR6-NEXT:    srlv $1, $1, $10
3862; MMR6-NEXT:    seh $1, $1
3863; MMR6-NEXT:  # %bb.3: # %entry
3864; MMR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3865; MMR6-NEXT:  # %bb.4: # %entry
3866; MMR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
3867; MMR6-NEXT:    sync
3868; MMR6-NEXT:    addiu $sp, $sp, 8
3869; MMR6-NEXT:    jrc $ra
3870;
3871; MIPSEL-LABEL: test_umax_8:
3872; MIPSEL:       # %bb.0: # %entry
3873; MIPSEL-NEXT:    addiu $sp, $sp, -8
3874; MIPSEL-NEXT:    .cfi_def_cfa_offset 8
3875; MIPSEL-NEXT:    # kill: def $at killed $a1
3876; MIPSEL-NEXT:    sync
3877; MIPSEL-NEXT:    addiu $1, $zero, -4
3878; MIPSEL-NEXT:    and $6, $4, $1
3879; MIPSEL-NEXT:    andi $1, $4, 3
3880; MIPSEL-NEXT:    sll $10, $1, 3
3881; MIPSEL-NEXT:    ori $1, $zero, 255
3882; MIPSEL-NEXT:    sllv $8, $1, $10
3883; MIPSEL-NEXT:    nor $9, $zero, $8
3884; MIPSEL-NEXT:    sllv $7, $5, $10
3885; MIPSEL-NEXT:  $BB10_1: # %entry
3886; MIPSEL-NEXT:    # =>This Inner Loop Header: Depth=1
3887; MIPSEL-NEXT:    ll $2, 0($6)
3888; MIPSEL-NEXT:    and $2, $2, $8
3889; MIPSEL-NEXT:    and $7, $7, $8
3890; MIPSEL-NEXT:    sltu $5, $2, $7
3891; MIPSEL-NEXT:    move $3, $2
3892; MIPSEL-NEXT:    movn $3, $7, $5
3893; MIPSEL-NEXT:    and $3, $3, $8
3894; MIPSEL-NEXT:    and $4, $2, $9
3895; MIPSEL-NEXT:    or $4, $4, $3
3896; MIPSEL-NEXT:    sc $4, 0($6)
3897; MIPSEL-NEXT:    beqz $4, $BB10_1
3898; MIPSEL-NEXT:    nop
3899; MIPSEL-NEXT:  # %bb.2: # %entry
3900; MIPSEL-NEXT:    and $1, $2, $8
3901; MIPSEL-NEXT:    srlv $1, $1, $10
3902; MIPSEL-NEXT:    seh $1, $1
3903; MIPSEL-NEXT:  # %bb.3: # %entry
3904; MIPSEL-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3905; MIPSEL-NEXT:  # %bb.4: # %entry
3906; MIPSEL-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
3907; MIPSEL-NEXT:    sync
3908; MIPSEL-NEXT:    addiu $sp, $sp, 8
3909; MIPSEL-NEXT:    jr $ra
3910; MIPSEL-NEXT:    nop
3911;
3912; MIPSELR6-LABEL: test_umax_8:
3913; MIPSELR6:       # %bb.0: # %entry
3914; MIPSELR6-NEXT:    addiu $sp, $sp, -8
3915; MIPSELR6-NEXT:    .cfi_def_cfa_offset 8
3916; MIPSELR6-NEXT:    # kill: def $at killed $a1
3917; MIPSELR6-NEXT:    sync
3918; MIPSELR6-NEXT:    addiu $1, $zero, -4
3919; MIPSELR6-NEXT:    and $6, $4, $1
3920; MIPSELR6-NEXT:    andi $1, $4, 3
3921; MIPSELR6-NEXT:    sll $10, $1, 3
3922; MIPSELR6-NEXT:    ori $1, $zero, 255
3923; MIPSELR6-NEXT:    sllv $8, $1, $10
3924; MIPSELR6-NEXT:    nor $9, $zero, $8
3925; MIPSELR6-NEXT:    sllv $7, $5, $10
3926; MIPSELR6-NEXT:  $BB10_1: # %entry
3927; MIPSELR6-NEXT:    # =>This Inner Loop Header: Depth=1
3928; MIPSELR6-NEXT:    ll $2, 0($6)
3929; MIPSELR6-NEXT:    and $2, $2, $8
3930; MIPSELR6-NEXT:    and $7, $7, $8
3931; MIPSELR6-NEXT:    sltu $5, $2, $7
3932; MIPSELR6-NEXT:    seleqz $3, $2, $5
3933; MIPSELR6-NEXT:    selnez $5, $7, $5
3934; MIPSELR6-NEXT:    or $3, $3, $5
3935; MIPSELR6-NEXT:    and $3, $3, $8
3936; MIPSELR6-NEXT:    and $4, $2, $9
3937; MIPSELR6-NEXT:    or $4, $4, $3
3938; MIPSELR6-NEXT:    sc $4, 0($6)
3939; MIPSELR6-NEXT:    beqzc $4, $BB10_1
3940; MIPSELR6-NEXT:  # %bb.2: # %entry
3941; MIPSELR6-NEXT:    and $1, $2, $8
3942; MIPSELR6-NEXT:    srlv $1, $1, $10
3943; MIPSELR6-NEXT:    seh $1, $1
3944; MIPSELR6-NEXT:  # %bb.3: # %entry
3945; MIPSELR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3946; MIPSELR6-NEXT:  # %bb.4: # %entry
3947; MIPSELR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
3948; MIPSELR6-NEXT:    sync
3949; MIPSELR6-NEXT:    addiu $sp, $sp, 8
3950; MIPSELR6-NEXT:    jrc $ra
3951;
3952; MMEL-LABEL: test_umax_8:
3953; MMEL:       # %bb.0: # %entry
3954; MMEL-NEXT:    addiu $sp, $sp, -8
3955; MMEL-NEXT:    .cfi_def_cfa_offset 8
3956; MMEL-NEXT:    # kill: def $at killed $a1
3957; MMEL-NEXT:    sync
3958; MMEL-NEXT:    addiu $1, $zero, -4
3959; MMEL-NEXT:    and $6, $4, $1
3960; MMEL-NEXT:    andi $1, $4, 3
3961; MMEL-NEXT:    sll $10, $1, 3
3962; MMEL-NEXT:    ori $1, $zero, 255
3963; MMEL-NEXT:    sllv $8, $1, $10
3964; MMEL-NEXT:    nor $9, $zero, $8
3965; MMEL-NEXT:    sllv $7, $5, $10
3966; MMEL-NEXT:  $BB10_1: # %entry
3967; MMEL-NEXT:    # =>This Inner Loop Header: Depth=1
3968; MMEL-NEXT:    ll $2, 0($6)
3969; MMEL-NEXT:    and $2, $2, $8
3970; MMEL-NEXT:    and $7, $7, $8
3971; MMEL-NEXT:    sltu $5, $2, $7
3972; MMEL-NEXT:    or $3, $2, $zero
3973; MMEL-NEXT:    movn $3, $7, $5
3974; MMEL-NEXT:    and $3, $3, $8
3975; MMEL-NEXT:    and $4, $2, $9
3976; MMEL-NEXT:    or $4, $4, $3
3977; MMEL-NEXT:    sc $4, 0($6)
3978; MMEL-NEXT:    beqzc $4, $BB10_1
3979; MMEL-NEXT:  # %bb.2: # %entry
3980; MMEL-NEXT:    and $1, $2, $8
3981; MMEL-NEXT:    srlv $1, $1, $10
3982; MMEL-NEXT:    seh $1, $1
3983; MMEL-NEXT:  # %bb.3: # %entry
3984; MMEL-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
3985; MMEL-NEXT:  # %bb.4: # %entry
3986; MMEL-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
3987; MMEL-NEXT:    sync
3988; MMEL-NEXT:    addiusp 8
3989; MMEL-NEXT:    jrc $ra
3990;
3991; MMELR6-LABEL: test_umax_8:
3992; MMELR6:       # %bb.0: # %entry
3993; MMELR6-NEXT:    addiu $sp, $sp, -8
3994; MMELR6-NEXT:    .cfi_def_cfa_offset 8
3995; MMELR6-NEXT:    # kill: def $at killed $a1
3996; MMELR6-NEXT:    sync
3997; MMELR6-NEXT:    addiu $1, $zero, -4
3998; MMELR6-NEXT:    and $6, $4, $1
3999; MMELR6-NEXT:    andi $1, $4, 3
4000; MMELR6-NEXT:    sll $10, $1, 3
4001; MMELR6-NEXT:    ori $1, $zero, 255
4002; MMELR6-NEXT:    sllv $8, $1, $10
4003; MMELR6-NEXT:    nor $9, $zero, $8
4004; MMELR6-NEXT:    sllv $7, $5, $10
4005; MMELR6-NEXT:  $BB10_1: # %entry
4006; MMELR6-NEXT:    # =>This Inner Loop Header: Depth=1
4007; MMELR6-NEXT:    ll $2, 0($6)
4008; MMELR6-NEXT:    and $2, $2, $8
4009; MMELR6-NEXT:    and $7, $7, $8
4010; MMELR6-NEXT:    sltu $5, $2, $7
4011; MMELR6-NEXT:    seleqz $3, $2, $5
4012; MMELR6-NEXT:    selnez $5, $7, $5
4013; MMELR6-NEXT:    or $3, $3, $5
4014; MMELR6-NEXT:    and $3, $3, $8
4015; MMELR6-NEXT:    and $4, $2, $9
4016; MMELR6-NEXT:    or $4, $4, $3
4017; MMELR6-NEXT:    sc $4, 0($6)
4018; MMELR6-NEXT:    beqc $4, $zero, $BB10_1
4019; MMELR6-NEXT:  # %bb.2: # %entry
4020; MMELR6-NEXT:    and $1, $2, $8
4021; MMELR6-NEXT:    srlv $1, $1, $10
4022; MMELR6-NEXT:    seh $1, $1
4023; MMELR6-NEXT:  # %bb.3: # %entry
4024; MMELR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
4025; MMELR6-NEXT:  # %bb.4: # %entry
4026; MMELR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
4027; MMELR6-NEXT:    sync
4028; MMELR6-NEXT:    addiu $sp, $sp, 8
4029; MMELR6-NEXT:    jrc $ra
4030;
4031; MIPS64-LABEL: test_umax_8:
4032; MIPS64:       # %bb.0: # %entry
4033; MIPS64-NEXT:    daddiu $sp, $sp, -16
4034; MIPS64-NEXT:    .cfi_def_cfa_offset 16
4035; MIPS64-NEXT:    move $1, $5
4036; MIPS64-NEXT:    sync
4037; MIPS64-NEXT:    daddiu $2, $zero, -4
4038; MIPS64-NEXT:    and $6, $4, $2
4039; MIPS64-NEXT:    andi $2, $4, 3
4040; MIPS64-NEXT:    xori $2, $2, 3
4041; MIPS64-NEXT:    sll $10, $2, 3
4042; MIPS64-NEXT:    ori $2, $zero, 255
4043; MIPS64-NEXT:    sllv $8, $2, $10
4044; MIPS64-NEXT:    nor $9, $zero, $8
4045; MIPS64-NEXT:    sllv $7, $1, $10
4046; MIPS64-NEXT:  .LBB10_1: # %entry
4047; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
4048; MIPS64-NEXT:    ll $2, 0($6)
4049; MIPS64-NEXT:    sltu $5, $2, $7
4050; MIPS64-NEXT:    move $3, $2
4051; MIPS64-NEXT:    movn $3, $7, $5
4052; MIPS64-NEXT:    and $3, $3, $8
4053; MIPS64-NEXT:    and $4, $2, $9
4054; MIPS64-NEXT:    or $4, $4, $3
4055; MIPS64-NEXT:    sc $4, 0($6)
4056; MIPS64-NEXT:    beqz $4, .LBB10_1
4057; MIPS64-NEXT:    nop
4058; MIPS64-NEXT:  # %bb.2: # %entry
4059; MIPS64-NEXT:    and $1, $2, $8
4060; MIPS64-NEXT:    srlv $1, $1, $10
4061; MIPS64-NEXT:    seh $1, $1
4062; MIPS64-NEXT:  # %bb.3: # %entry
4063; MIPS64-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
4064; MIPS64-NEXT:  # %bb.4: # %entry
4065; MIPS64-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
4066; MIPS64-NEXT:    sync
4067; MIPS64-NEXT:    daddiu $sp, $sp, 16
4068; MIPS64-NEXT:    jr $ra
4069; MIPS64-NEXT:    nop
4070;
4071; MIPS64R6-LABEL: test_umax_8:
4072; MIPS64R6:       # %bb.0: # %entry
4073; MIPS64R6-NEXT:    daddiu $sp, $sp, -16
4074; MIPS64R6-NEXT:    .cfi_def_cfa_offset 16
4075; MIPS64R6-NEXT:    move $1, $5
4076; MIPS64R6-NEXT:    sync
4077; MIPS64R6-NEXT:    daddiu $2, $zero, -4
4078; MIPS64R6-NEXT:    and $6, $4, $2
4079; MIPS64R6-NEXT:    andi $2, $4, 3
4080; MIPS64R6-NEXT:    xori $2, $2, 3
4081; MIPS64R6-NEXT:    sll $10, $2, 3
4082; MIPS64R6-NEXT:    ori $2, $zero, 255
4083; MIPS64R6-NEXT:    sllv $8, $2, $10
4084; MIPS64R6-NEXT:    nor $9, $zero, $8
4085; MIPS64R6-NEXT:    sllv $7, $1, $10
4086; MIPS64R6-NEXT:  .LBB10_1: # %entry
4087; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
4088; MIPS64R6-NEXT:    ll $2, 0($6)
4089; MIPS64R6-NEXT:    sltu $5, $2, $7
4090; MIPS64R6-NEXT:    seleqz $3, $2, $5
4091; MIPS64R6-NEXT:    selnez $5, $7, $5
4092; MIPS64R6-NEXT:    or $3, $3, $5
4093; MIPS64R6-NEXT:    and $3, $3, $8
4094; MIPS64R6-NEXT:    and $4, $2, $9
4095; MIPS64R6-NEXT:    or $4, $4, $3
4096; MIPS64R6-NEXT:    sc $4, 0($6)
4097; MIPS64R6-NEXT:    beqzc $4, .LBB10_1
4098; MIPS64R6-NEXT:  # %bb.2: # %entry
4099; MIPS64R6-NEXT:    and $1, $2, $8
4100; MIPS64R6-NEXT:    srlv $1, $1, $10
4101; MIPS64R6-NEXT:    seh $1, $1
4102; MIPS64R6-NEXT:  # %bb.3: # %entry
4103; MIPS64R6-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
4104; MIPS64R6-NEXT:  # %bb.4: # %entry
4105; MIPS64R6-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
4106; MIPS64R6-NEXT:    sync
4107; MIPS64R6-NEXT:    daddiu $sp, $sp, 16
4108; MIPS64R6-NEXT:    jrc $ra
4109;
4110; MIPS64EL-LABEL: test_umax_8:
4111; MIPS64EL:       # %bb.0: # %entry
4112; MIPS64EL-NEXT:    daddiu $sp, $sp, -16
4113; MIPS64EL-NEXT:    .cfi_def_cfa_offset 16
4114; MIPS64EL-NEXT:    move $1, $5
4115; MIPS64EL-NEXT:    sync
4116; MIPS64EL-NEXT:    daddiu $2, $zero, -4
4117; MIPS64EL-NEXT:    and $6, $4, $2
4118; MIPS64EL-NEXT:    andi $2, $4, 3
4119; MIPS64EL-NEXT:    sll $10, $2, 3
4120; MIPS64EL-NEXT:    ori $2, $zero, 255
4121; MIPS64EL-NEXT:    sllv $8, $2, $10
4122; MIPS64EL-NEXT:    nor $9, $zero, $8
4123; MIPS64EL-NEXT:    sllv $7, $1, $10
4124; MIPS64EL-NEXT:  .LBB10_1: # %entry
4125; MIPS64EL-NEXT:    # =>This Inner Loop Header: Depth=1
4126; MIPS64EL-NEXT:    ll $2, 0($6)
4127; MIPS64EL-NEXT:    and $2, $2, $8
4128; MIPS64EL-NEXT:    and $7, $7, $8
4129; MIPS64EL-NEXT:    sltu $5, $2, $7
4130; MIPS64EL-NEXT:    move $3, $2
4131; MIPS64EL-NEXT:    movn $3, $7, $5
4132; MIPS64EL-NEXT:    and $3, $3, $8
4133; MIPS64EL-NEXT:    and $4, $2, $9
4134; MIPS64EL-NEXT:    or $4, $4, $3
4135; MIPS64EL-NEXT:    sc $4, 0($6)
4136; MIPS64EL-NEXT:    beqz $4, .LBB10_1
4137; MIPS64EL-NEXT:    nop
4138; MIPS64EL-NEXT:  # %bb.2: # %entry
4139; MIPS64EL-NEXT:    and $1, $2, $8
4140; MIPS64EL-NEXT:    srlv $1, $1, $10
4141; MIPS64EL-NEXT:    seh $1, $1
4142; MIPS64EL-NEXT:  # %bb.3: # %entry
4143; MIPS64EL-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
4144; MIPS64EL-NEXT:  # %bb.4: # %entry
4145; MIPS64EL-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
4146; MIPS64EL-NEXT:    sync
4147; MIPS64EL-NEXT:    daddiu $sp, $sp, 16
4148; MIPS64EL-NEXT:    jr $ra
4149; MIPS64EL-NEXT:    nop
4150;
4151; MIPS64ELR6-LABEL: test_umax_8:
4152; MIPS64ELR6:       # %bb.0: # %entry
4153; MIPS64ELR6-NEXT:    daddiu $sp, $sp, -16
4154; MIPS64ELR6-NEXT:    .cfi_def_cfa_offset 16
4155; MIPS64ELR6-NEXT:    move $1, $5
4156; MIPS64ELR6-NEXT:    sync
4157; MIPS64ELR6-NEXT:    daddiu $2, $zero, -4
4158; MIPS64ELR6-NEXT:    and $6, $4, $2
4159; MIPS64ELR6-NEXT:    andi $2, $4, 3
4160; MIPS64ELR6-NEXT:    sll $10, $2, 3
4161; MIPS64ELR6-NEXT:    ori $2, $zero, 255
4162; MIPS64ELR6-NEXT:    sllv $8, $2, $10
4163; MIPS64ELR6-NEXT:    nor $9, $zero, $8
4164; MIPS64ELR6-NEXT:    sllv $7, $1, $10
4165; MIPS64ELR6-NEXT:  .LBB10_1: # %entry
4166; MIPS64ELR6-NEXT:    # =>This Inner Loop Header: Depth=1
4167; MIPS64ELR6-NEXT:    ll $2, 0($6)
4168; MIPS64ELR6-NEXT:    and $2, $2, $8
4169; MIPS64ELR6-NEXT:    and $7, $7, $8
4170; MIPS64ELR6-NEXT:    sltu $5, $2, $7
4171; MIPS64ELR6-NEXT:    seleqz $3, $2, $5
4172; MIPS64ELR6-NEXT:    selnez $5, $7, $5
4173; MIPS64ELR6-NEXT:    or $3, $3, $5
4174; MIPS64ELR6-NEXT:    and $3, $3, $8
4175; MIPS64ELR6-NEXT:    and $4, $2, $9
4176; MIPS64ELR6-NEXT:    or $4, $4, $3
4177; MIPS64ELR6-NEXT:    sc $4, 0($6)
4178; MIPS64ELR6-NEXT:    beqzc $4, .LBB10_1
4179; MIPS64ELR6-NEXT:  # %bb.2: # %entry
4180; MIPS64ELR6-NEXT:    and $1, $2, $8
4181; MIPS64ELR6-NEXT:    srlv $1, $1, $10
4182; MIPS64ELR6-NEXT:    seh $1, $1
4183; MIPS64ELR6-NEXT:  # %bb.3: # %entry
4184; MIPS64ELR6-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
4185; MIPS64ELR6-NEXT:  # %bb.4: # %entry
4186; MIPS64ELR6-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
4187; MIPS64ELR6-NEXT:    sync
4188; MIPS64ELR6-NEXT:    daddiu $sp, $sp, 16
4189; MIPS64ELR6-NEXT:    jrc $ra
4190entry:
4191  %0 = atomicrmw umax i8* %ptr, i8 %val seq_cst
4192  ret i8 %0
4193}
4194
4195define i8 @test_umin_8(i8* nocapture %ptr, i8 signext %val) {
4196; MIPS-LABEL: test_umin_8:
4197; MIPS:       # %bb.0: # %entry
4198; MIPS-NEXT:    addiu $sp, $sp, -8
4199; MIPS-NEXT:    .cfi_def_cfa_offset 8
4200; MIPS-NEXT:    # kill: def $at killed $a1
4201; MIPS-NEXT:    sync
4202; MIPS-NEXT:    addiu $1, $zero, -4
4203; MIPS-NEXT:    and $6, $4, $1
4204; MIPS-NEXT:    andi $1, $4, 3
4205; MIPS-NEXT:    xori $1, $1, 3
4206; MIPS-NEXT:    sll $10, $1, 3
4207; MIPS-NEXT:    ori $1, $zero, 255
4208; MIPS-NEXT:    sllv $8, $1, $10
4209; MIPS-NEXT:    nor $9, $zero, $8
4210; MIPS-NEXT:    sllv $7, $5, $10
4211; MIPS-NEXT:  $BB11_1: # %entry
4212; MIPS-NEXT:    # =>This Inner Loop Header: Depth=1
4213; MIPS-NEXT:    ll $2, 0($6)
4214; MIPS-NEXT:    sltu $5, $2, $7
4215; MIPS-NEXT:    move $3, $2
4216; MIPS-NEXT:    movz $3, $7, $5
4217; MIPS-NEXT:    and $3, $3, $8
4218; MIPS-NEXT:    and $4, $2, $9
4219; MIPS-NEXT:    or $4, $4, $3
4220; MIPS-NEXT:    sc $4, 0($6)
4221; MIPS-NEXT:    beqz $4, $BB11_1
4222; MIPS-NEXT:    nop
4223; MIPS-NEXT:  # %bb.2: # %entry
4224; MIPS-NEXT:    and $1, $2, $8
4225; MIPS-NEXT:    srlv $1, $1, $10
4226; MIPS-NEXT:    seh $1, $1
4227; MIPS-NEXT:  # %bb.3: # %entry
4228; MIPS-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
4229; MIPS-NEXT:  # %bb.4: # %entry
4230; MIPS-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
4231; MIPS-NEXT:    sync
4232; MIPS-NEXT:    addiu $sp, $sp, 8
4233; MIPS-NEXT:    jr $ra
4234; MIPS-NEXT:    nop
4235;
4236; MIPSR6-LABEL: test_umin_8:
4237; MIPSR6:       # %bb.0: # %entry
4238; MIPSR6-NEXT:    addiu $sp, $sp, -8
4239; MIPSR6-NEXT:    .cfi_def_cfa_offset 8
4240; MIPSR6-NEXT:    # kill: def $at killed $a1
4241; MIPSR6-NEXT:    sync
4242; MIPSR6-NEXT:    addiu $1, $zero, -4
4243; MIPSR6-NEXT:    and $6, $4, $1
4244; MIPSR6-NEXT:    andi $1, $4, 3
4245; MIPSR6-NEXT:    xori $1, $1, 3
4246; MIPSR6-NEXT:    sll $10, $1, 3
4247; MIPSR6-NEXT:    ori $1, $zero, 255
4248; MIPSR6-NEXT:    sllv $8, $1, $10
4249; MIPSR6-NEXT:    nor $9, $zero, $8
4250; MIPSR6-NEXT:    sllv $7, $5, $10
4251; MIPSR6-NEXT:  $BB11_1: # %entry
4252; MIPSR6-NEXT:    # =>This Inner Loop Header: Depth=1
4253; MIPSR6-NEXT:    ll $2, 0($6)
4254; MIPSR6-NEXT:    sltu $5, $2, $7
4255; MIPSR6-NEXT:    selnez $3, $2, $5
4256; MIPSR6-NEXT:    seleqz $5, $7, $5
4257; MIPSR6-NEXT:    or $3, $3, $5
4258; MIPSR6-NEXT:    and $3, $3, $8
4259; MIPSR6-NEXT:    and $4, $2, $9
4260; MIPSR6-NEXT:    or $4, $4, $3
4261; MIPSR6-NEXT:    sc $4, 0($6)
4262; MIPSR6-NEXT:    beqzc $4, $BB11_1
4263; MIPSR6-NEXT:  # %bb.2: # %entry
4264; MIPSR6-NEXT:    and $1, $2, $8
4265; MIPSR6-NEXT:    srlv $1, $1, $10
4266; MIPSR6-NEXT:    seh $1, $1
4267; MIPSR6-NEXT:  # %bb.3: # %entry
4268; MIPSR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
4269; MIPSR6-NEXT:  # %bb.4: # %entry
4270; MIPSR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
4271; MIPSR6-NEXT:    sync
4272; MIPSR6-NEXT:    addiu $sp, $sp, 8
4273; MIPSR6-NEXT:    jrc $ra
4274;
4275; MM-LABEL: test_umin_8:
4276; MM:       # %bb.0: # %entry
4277; MM-NEXT:    addiu $sp, $sp, -8
4278; MM-NEXT:    .cfi_def_cfa_offset 8
4279; MM-NEXT:    # kill: def $at killed $a1
4280; MM-NEXT:    sync
4281; MM-NEXT:    addiu $1, $zero, -4
4282; MM-NEXT:    and $6, $4, $1
4283; MM-NEXT:    andi $1, $4, 3
4284; MM-NEXT:    xori $1, $1, 3
4285; MM-NEXT:    sll $10, $1, 3
4286; MM-NEXT:    ori $1, $zero, 255
4287; MM-NEXT:    sllv $8, $1, $10
4288; MM-NEXT:    nor $9, $zero, $8
4289; MM-NEXT:    sllv $7, $5, $10
4290; MM-NEXT:  $BB11_1: # %entry
4291; MM-NEXT:    # =>This Inner Loop Header: Depth=1
4292; MM-NEXT:    ll $2, 0($6)
4293; MM-NEXT:    sltu $5, $2, $7
4294; MM-NEXT:    or $3, $2, $zero
4295; MM-NEXT:    movz $3, $7, $5
4296; MM-NEXT:    and $3, $3, $8
4297; MM-NEXT:    and $4, $2, $9
4298; MM-NEXT:    or $4, $4, $3
4299; MM-NEXT:    sc $4, 0($6)
4300; MM-NEXT:    beqzc $4, $BB11_1
4301; MM-NEXT:  # %bb.2: # %entry
4302; MM-NEXT:    and $1, $2, $8
4303; MM-NEXT:    srlv $1, $1, $10
4304; MM-NEXT:    seh $1, $1
4305; MM-NEXT:  # %bb.3: # %entry
4306; MM-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
4307; MM-NEXT:  # %bb.4: # %entry
4308; MM-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
4309; MM-NEXT:    sync
4310; MM-NEXT:    addiusp 8
4311; MM-NEXT:    jrc $ra
4312;
4313; MMR6-LABEL: test_umin_8:
4314; MMR6:       # %bb.0: # %entry
4315; MMR6-NEXT:    addiu $sp, $sp, -8
4316; MMR6-NEXT:    .cfi_def_cfa_offset 8
4317; MMR6-NEXT:    # kill: def $at killed $a1
4318; MMR6-NEXT:    sync
4319; MMR6-NEXT:    addiu $1, $zero, -4
4320; MMR6-NEXT:    and $6, $4, $1
4321; MMR6-NEXT:    andi $1, $4, 3
4322; MMR6-NEXT:    xori $1, $1, 3
4323; MMR6-NEXT:    sll $10, $1, 3
4324; MMR6-NEXT:    ori $1, $zero, 255
4325; MMR6-NEXT:    sllv $8, $1, $10
4326; MMR6-NEXT:    nor $9, $zero, $8
4327; MMR6-NEXT:    sllv $7, $5, $10
4328; MMR6-NEXT:  $BB11_1: # %entry
4329; MMR6-NEXT:    # =>This Inner Loop Header: Depth=1
4330; MMR6-NEXT:    ll $2, 0($6)
4331; MMR6-NEXT:    sltu $5, $2, $7
4332; MMR6-NEXT:    selnez $3, $2, $5
4333; MMR6-NEXT:    seleqz $5, $7, $5
4334; MMR6-NEXT:    or $3, $3, $5
4335; MMR6-NEXT:    and $3, $3, $8
4336; MMR6-NEXT:    and $4, $2, $9
4337; MMR6-NEXT:    or $4, $4, $3
4338; MMR6-NEXT:    sc $4, 0($6)
4339; MMR6-NEXT:    beqc $4, $zero, $BB11_1
4340; MMR6-NEXT:  # %bb.2: # %entry
4341; MMR6-NEXT:    and $1, $2, $8
4342; MMR6-NEXT:    srlv $1, $1, $10
4343; MMR6-NEXT:    seh $1, $1
4344; MMR6-NEXT:  # %bb.3: # %entry
4345; MMR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
4346; MMR6-NEXT:  # %bb.4: # %entry
4347; MMR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
4348; MMR6-NEXT:    sync
4349; MMR6-NEXT:    addiu $sp, $sp, 8
4350; MMR6-NEXT:    jrc $ra
4351;
4352; MIPSEL-LABEL: test_umin_8:
4353; MIPSEL:       # %bb.0: # %entry
4354; MIPSEL-NEXT:    addiu $sp, $sp, -8
4355; MIPSEL-NEXT:    .cfi_def_cfa_offset 8
4356; MIPSEL-NEXT:    # kill: def $at killed $a1
4357; MIPSEL-NEXT:    sync
4358; MIPSEL-NEXT:    addiu $1, $zero, -4
4359; MIPSEL-NEXT:    and $6, $4, $1
4360; MIPSEL-NEXT:    andi $1, $4, 3
4361; MIPSEL-NEXT:    sll $10, $1, 3
4362; MIPSEL-NEXT:    ori $1, $zero, 255
4363; MIPSEL-NEXT:    sllv $8, $1, $10
4364; MIPSEL-NEXT:    nor $9, $zero, $8
4365; MIPSEL-NEXT:    sllv $7, $5, $10
4366; MIPSEL-NEXT:  $BB11_1: # %entry
4367; MIPSEL-NEXT:    # =>This Inner Loop Header: Depth=1
4368; MIPSEL-NEXT:    ll $2, 0($6)
4369; MIPSEL-NEXT:    and $2, $2, $8
4370; MIPSEL-NEXT:    and $7, $7, $8
4371; MIPSEL-NEXT:    sltu $5, $2, $7
4372; MIPSEL-NEXT:    move $3, $2
4373; MIPSEL-NEXT:    movz $3, $7, $5
4374; MIPSEL-NEXT:    and $3, $3, $8
4375; MIPSEL-NEXT:    and $4, $2, $9
4376; MIPSEL-NEXT:    or $4, $4, $3
4377; MIPSEL-NEXT:    sc $4, 0($6)
4378; MIPSEL-NEXT:    beqz $4, $BB11_1
4379; MIPSEL-NEXT:    nop
4380; MIPSEL-NEXT:  # %bb.2: # %entry
4381; MIPSEL-NEXT:    and $1, $2, $8
4382; MIPSEL-NEXT:    srlv $1, $1, $10
4383; MIPSEL-NEXT:    seh $1, $1
4384; MIPSEL-NEXT:  # %bb.3: # %entry
4385; MIPSEL-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
4386; MIPSEL-NEXT:  # %bb.4: # %entry
4387; MIPSEL-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
4388; MIPSEL-NEXT:    sync
4389; MIPSEL-NEXT:    addiu $sp, $sp, 8
4390; MIPSEL-NEXT:    jr $ra
4391; MIPSEL-NEXT:    nop
4392;
4393; MIPSELR6-LABEL: test_umin_8:
4394; MIPSELR6:       # %bb.0: # %entry
4395; MIPSELR6-NEXT:    addiu $sp, $sp, -8
4396; MIPSELR6-NEXT:    .cfi_def_cfa_offset 8
4397; MIPSELR6-NEXT:    # kill: def $at killed $a1
4398; MIPSELR6-NEXT:    sync
4399; MIPSELR6-NEXT:    addiu $1, $zero, -4
4400; MIPSELR6-NEXT:    and $6, $4, $1
4401; MIPSELR6-NEXT:    andi $1, $4, 3
4402; MIPSELR6-NEXT:    sll $10, $1, 3
4403; MIPSELR6-NEXT:    ori $1, $zero, 255
4404; MIPSELR6-NEXT:    sllv $8, $1, $10
4405; MIPSELR6-NEXT:    nor $9, $zero, $8
4406; MIPSELR6-NEXT:    sllv $7, $5, $10
4407; MIPSELR6-NEXT:  $BB11_1: # %entry
4408; MIPSELR6-NEXT:    # =>This Inner Loop Header: Depth=1
4409; MIPSELR6-NEXT:    ll $2, 0($6)
4410; MIPSELR6-NEXT:    and $2, $2, $8
4411; MIPSELR6-NEXT:    and $7, $7, $8
4412; MIPSELR6-NEXT:    sltu $5, $2, $7
4413; MIPSELR6-NEXT:    selnez $3, $2, $5
4414; MIPSELR6-NEXT:    seleqz $5, $7, $5
4415; MIPSELR6-NEXT:    or $3, $3, $5
4416; MIPSELR6-NEXT:    and $3, $3, $8
4417; MIPSELR6-NEXT:    and $4, $2, $9
4418; MIPSELR6-NEXT:    or $4, $4, $3
4419; MIPSELR6-NEXT:    sc $4, 0($6)
4420; MIPSELR6-NEXT:    beqzc $4, $BB11_1
4421; MIPSELR6-NEXT:  # %bb.2: # %entry
4422; MIPSELR6-NEXT:    and $1, $2, $8
4423; MIPSELR6-NEXT:    srlv $1, $1, $10
4424; MIPSELR6-NEXT:    seh $1, $1
4425; MIPSELR6-NEXT:  # %bb.3: # %entry
4426; MIPSELR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
4427; MIPSELR6-NEXT:  # %bb.4: # %entry
4428; MIPSELR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
4429; MIPSELR6-NEXT:    sync
4430; MIPSELR6-NEXT:    addiu $sp, $sp, 8
4431; MIPSELR6-NEXT:    jrc $ra
4432;
4433; MMEL-LABEL: test_umin_8:
4434; MMEL:       # %bb.0: # %entry
4435; MMEL-NEXT:    addiu $sp, $sp, -8
4436; MMEL-NEXT:    .cfi_def_cfa_offset 8
4437; MMEL-NEXT:    # kill: def $at killed $a1
4438; MMEL-NEXT:    sync
4439; MMEL-NEXT:    addiu $1, $zero, -4
4440; MMEL-NEXT:    and $6, $4, $1
4441; MMEL-NEXT:    andi $1, $4, 3
4442; MMEL-NEXT:    sll $10, $1, 3
4443; MMEL-NEXT:    ori $1, $zero, 255
4444; MMEL-NEXT:    sllv $8, $1, $10
4445; MMEL-NEXT:    nor $9, $zero, $8
4446; MMEL-NEXT:    sllv $7, $5, $10
4447; MMEL-NEXT:  $BB11_1: # %entry
4448; MMEL-NEXT:    # =>This Inner Loop Header: Depth=1
4449; MMEL-NEXT:    ll $2, 0($6)
4450; MMEL-NEXT:    and $2, $2, $8
4451; MMEL-NEXT:    and $7, $7, $8
4452; MMEL-NEXT:    sltu $5, $2, $7
4453; MMEL-NEXT:    or $3, $2, $zero
4454; MMEL-NEXT:    movz $3, $7, $5
4455; MMEL-NEXT:    and $3, $3, $8
4456; MMEL-NEXT:    and $4, $2, $9
4457; MMEL-NEXT:    or $4, $4, $3
4458; MMEL-NEXT:    sc $4, 0($6)
4459; MMEL-NEXT:    beqzc $4, $BB11_1
4460; MMEL-NEXT:  # %bb.2: # %entry
4461; MMEL-NEXT:    and $1, $2, $8
4462; MMEL-NEXT:    srlv $1, $1, $10
4463; MMEL-NEXT:    seh $1, $1
4464; MMEL-NEXT:  # %bb.3: # %entry
4465; MMEL-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
4466; MMEL-NEXT:  # %bb.4: # %entry
4467; MMEL-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
4468; MMEL-NEXT:    sync
4469; MMEL-NEXT:    addiusp 8
4470; MMEL-NEXT:    jrc $ra
4471;
4472; MMELR6-LABEL: test_umin_8:
4473; MMELR6:       # %bb.0: # %entry
4474; MMELR6-NEXT:    addiu $sp, $sp, -8
4475; MMELR6-NEXT:    .cfi_def_cfa_offset 8
4476; MMELR6-NEXT:    # kill: def $at killed $a1
4477; MMELR6-NEXT:    sync
4478; MMELR6-NEXT:    addiu $1, $zero, -4
4479; MMELR6-NEXT:    and $6, $4, $1
4480; MMELR6-NEXT:    andi $1, $4, 3
4481; MMELR6-NEXT:    sll $10, $1, 3
4482; MMELR6-NEXT:    ori $1, $zero, 255
4483; MMELR6-NEXT:    sllv $8, $1, $10
4484; MMELR6-NEXT:    nor $9, $zero, $8
4485; MMELR6-NEXT:    sllv $7, $5, $10
4486; MMELR6-NEXT:  $BB11_1: # %entry
4487; MMELR6-NEXT:    # =>This Inner Loop Header: Depth=1
4488; MMELR6-NEXT:    ll $2, 0($6)
4489; MMELR6-NEXT:    and $2, $2, $8
4490; MMELR6-NEXT:    and $7, $7, $8
4491; MMELR6-NEXT:    sltu $5, $2, $7
4492; MMELR6-NEXT:    selnez $3, $2, $5
4493; MMELR6-NEXT:    seleqz $5, $7, $5
4494; MMELR6-NEXT:    or $3, $3, $5
4495; MMELR6-NEXT:    and $3, $3, $8
4496; MMELR6-NEXT:    and $4, $2, $9
4497; MMELR6-NEXT:    or $4, $4, $3
4498; MMELR6-NEXT:    sc $4, 0($6)
4499; MMELR6-NEXT:    beqc $4, $zero, $BB11_1
4500; MMELR6-NEXT:  # %bb.2: # %entry
4501; MMELR6-NEXT:    and $1, $2, $8
4502; MMELR6-NEXT:    srlv $1, $1, $10
4503; MMELR6-NEXT:    seh $1, $1
4504; MMELR6-NEXT:  # %bb.3: # %entry
4505; MMELR6-NEXT:    sw $1, 4($sp) # 4-byte Folded Spill
4506; MMELR6-NEXT:  # %bb.4: # %entry
4507; MMELR6-NEXT:    lw $2, 4($sp) # 4-byte Folded Reload
4508; MMELR6-NEXT:    sync
4509; MMELR6-NEXT:    addiu $sp, $sp, 8
4510; MMELR6-NEXT:    jrc $ra
4511;
4512; MIPS64-LABEL: test_umin_8:
4513; MIPS64:       # %bb.0: # %entry
4514; MIPS64-NEXT:    daddiu $sp, $sp, -16
4515; MIPS64-NEXT:    .cfi_def_cfa_offset 16
4516; MIPS64-NEXT:    move $1, $5
4517; MIPS64-NEXT:    sync
4518; MIPS64-NEXT:    daddiu $2, $zero, -4
4519; MIPS64-NEXT:    and $6, $4, $2
4520; MIPS64-NEXT:    andi $2, $4, 3
4521; MIPS64-NEXT:    xori $2, $2, 3
4522; MIPS64-NEXT:    sll $10, $2, 3
4523; MIPS64-NEXT:    ori $2, $zero, 255
4524; MIPS64-NEXT:    sllv $8, $2, $10
4525; MIPS64-NEXT:    nor $9, $zero, $8
4526; MIPS64-NEXT:    sllv $7, $1, $10
4527; MIPS64-NEXT:  .LBB11_1: # %entry
4528; MIPS64-NEXT:    # =>This Inner Loop Header: Depth=1
4529; MIPS64-NEXT:    ll $2, 0($6)
4530; MIPS64-NEXT:    sltu $5, $2, $7
4531; MIPS64-NEXT:    move $3, $2
4532; MIPS64-NEXT:    movz $3, $7, $5
4533; MIPS64-NEXT:    and $3, $3, $8
4534; MIPS64-NEXT:    and $4, $2, $9
4535; MIPS64-NEXT:    or $4, $4, $3
4536; MIPS64-NEXT:    sc $4, 0($6)
4537; MIPS64-NEXT:    beqz $4, .LBB11_1
4538; MIPS64-NEXT:    nop
4539; MIPS64-NEXT:  # %bb.2: # %entry
4540; MIPS64-NEXT:    and $1, $2, $8
4541; MIPS64-NEXT:    srlv $1, $1, $10
4542; MIPS64-NEXT:    seh $1, $1
4543; MIPS64-NEXT:  # %bb.3: # %entry
4544; MIPS64-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
4545; MIPS64-NEXT:  # %bb.4: # %entry
4546; MIPS64-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
4547; MIPS64-NEXT:    sync
4548; MIPS64-NEXT:    daddiu $sp, $sp, 16
4549; MIPS64-NEXT:    jr $ra
4550; MIPS64-NEXT:    nop
4551;
4552; MIPS64R6-LABEL: test_umin_8:
4553; MIPS64R6:       # %bb.0: # %entry
4554; MIPS64R6-NEXT:    daddiu $sp, $sp, -16
4555; MIPS64R6-NEXT:    .cfi_def_cfa_offset 16
4556; MIPS64R6-NEXT:    move $1, $5
4557; MIPS64R6-NEXT:    sync
4558; MIPS64R6-NEXT:    daddiu $2, $zero, -4
4559; MIPS64R6-NEXT:    and $6, $4, $2
4560; MIPS64R6-NEXT:    andi $2, $4, 3
4561; MIPS64R6-NEXT:    xori $2, $2, 3
4562; MIPS64R6-NEXT:    sll $10, $2, 3
4563; MIPS64R6-NEXT:    ori $2, $zero, 255
4564; MIPS64R6-NEXT:    sllv $8, $2, $10
4565; MIPS64R6-NEXT:    nor $9, $zero, $8
4566; MIPS64R6-NEXT:    sllv $7, $1, $10
4567; MIPS64R6-NEXT:  .LBB11_1: # %entry
4568; MIPS64R6-NEXT:    # =>This Inner Loop Header: Depth=1
4569; MIPS64R6-NEXT:    ll $2, 0($6)
4570; MIPS64R6-NEXT:    sltu $5, $2, $7
4571; MIPS64R6-NEXT:    selnez $3, $2, $5
4572; MIPS64R6-NEXT:    seleqz $5, $7, $5
4573; MIPS64R6-NEXT:    or $3, $3, $5
4574; MIPS64R6-NEXT:    and $3, $3, $8
4575; MIPS64R6-NEXT:    and $4, $2, $9
4576; MIPS64R6-NEXT:    or $4, $4, $3
4577; MIPS64R6-NEXT:    sc $4, 0($6)
4578; MIPS64R6-NEXT:    beqzc $4, .LBB11_1
4579; MIPS64R6-NEXT:  # %bb.2: # %entry
4580; MIPS64R6-NEXT:    and $1, $2, $8
4581; MIPS64R6-NEXT:    srlv $1, $1, $10
4582; MIPS64R6-NEXT:    seh $1, $1
4583; MIPS64R6-NEXT:  # %bb.3: # %entry
4584; MIPS64R6-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
4585; MIPS64R6-NEXT:  # %bb.4: # %entry
4586; MIPS64R6-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
4587; MIPS64R6-NEXT:    sync
4588; MIPS64R6-NEXT:    daddiu $sp, $sp, 16
4589; MIPS64R6-NEXT:    jrc $ra
4590;
4591; MIPS64EL-LABEL: test_umin_8:
4592; MIPS64EL:       # %bb.0: # %entry
4593; MIPS64EL-NEXT:    daddiu $sp, $sp, -16
4594; MIPS64EL-NEXT:    .cfi_def_cfa_offset 16
4595; MIPS64EL-NEXT:    move $1, $5
4596; MIPS64EL-NEXT:    sync
4597; MIPS64EL-NEXT:    daddiu $2, $zero, -4
4598; MIPS64EL-NEXT:    and $6, $4, $2
4599; MIPS64EL-NEXT:    andi $2, $4, 3
4600; MIPS64EL-NEXT:    sll $10, $2, 3
4601; MIPS64EL-NEXT:    ori $2, $zero, 255
4602; MIPS64EL-NEXT:    sllv $8, $2, $10
4603; MIPS64EL-NEXT:    nor $9, $zero, $8
4604; MIPS64EL-NEXT:    sllv $7, $1, $10
4605; MIPS64EL-NEXT:  .LBB11_1: # %entry
4606; MIPS64EL-NEXT:    # =>This Inner Loop Header: Depth=1
4607; MIPS64EL-NEXT:    ll $2, 0($6)
4608; MIPS64EL-NEXT:    and $2, $2, $8
4609; MIPS64EL-NEXT:    and $7, $7, $8
4610; MIPS64EL-NEXT:    sltu $5, $2, $7
4611; MIPS64EL-NEXT:    move $3, $2
4612; MIPS64EL-NEXT:    movz $3, $7, $5
4613; MIPS64EL-NEXT:    and $3, $3, $8
4614; MIPS64EL-NEXT:    and $4, $2, $9
4615; MIPS64EL-NEXT:    or $4, $4, $3
4616; MIPS64EL-NEXT:    sc $4, 0($6)
4617; MIPS64EL-NEXT:    beqz $4, .LBB11_1
4618; MIPS64EL-NEXT:    nop
4619; MIPS64EL-NEXT:  # %bb.2: # %entry
4620; MIPS64EL-NEXT:    and $1, $2, $8
4621; MIPS64EL-NEXT:    srlv $1, $1, $10
4622; MIPS64EL-NEXT:    seh $1, $1
4623; MIPS64EL-NEXT:  # %bb.3: # %entry
4624; MIPS64EL-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
4625; MIPS64EL-NEXT:  # %bb.4: # %entry
4626; MIPS64EL-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
4627; MIPS64EL-NEXT:    sync
4628; MIPS64EL-NEXT:    daddiu $sp, $sp, 16
4629; MIPS64EL-NEXT:    jr $ra
4630; MIPS64EL-NEXT:    nop
4631;
4632; MIPS64ELR6-LABEL: test_umin_8:
4633; MIPS64ELR6:       # %bb.0: # %entry
4634; MIPS64ELR6-NEXT:    daddiu $sp, $sp, -16
4635; MIPS64ELR6-NEXT:    .cfi_def_cfa_offset 16
4636; MIPS64ELR6-NEXT:    move $1, $5
4637; MIPS64ELR6-NEXT:    sync
4638; MIPS64ELR6-NEXT:    daddiu $2, $zero, -4
4639; MIPS64ELR6-NEXT:    and $6, $4, $2
4640; MIPS64ELR6-NEXT:    andi $2, $4, 3
4641; MIPS64ELR6-NEXT:    sll $10, $2, 3
4642; MIPS64ELR6-NEXT:    ori $2, $zero, 255
4643; MIPS64ELR6-NEXT:    sllv $8, $2, $10
4644; MIPS64ELR6-NEXT:    nor $9, $zero, $8
4645; MIPS64ELR6-NEXT:    sllv $7, $1, $10
4646; MIPS64ELR6-NEXT:  .LBB11_1: # %entry
4647; MIPS64ELR6-NEXT:    # =>This Inner Loop Header: Depth=1
4648; MIPS64ELR6-NEXT:    ll $2, 0($6)
4649; MIPS64ELR6-NEXT:    and $2, $2, $8
4650; MIPS64ELR6-NEXT:    and $7, $7, $8
4651; MIPS64ELR6-NEXT:    sltu $5, $2, $7
4652; MIPS64ELR6-NEXT:    selnez $3, $2, $5
4653; MIPS64ELR6-NEXT:    seleqz $5, $7, $5
4654; MIPS64ELR6-NEXT:    or $3, $3, $5
4655; MIPS64ELR6-NEXT:    and $3, $3, $8
4656; MIPS64ELR6-NEXT:    and $4, $2, $9
4657; MIPS64ELR6-NEXT:    or $4, $4, $3
4658; MIPS64ELR6-NEXT:    sc $4, 0($6)
4659; MIPS64ELR6-NEXT:    beqzc $4, .LBB11_1
4660; MIPS64ELR6-NEXT:  # %bb.2: # %entry
4661; MIPS64ELR6-NEXT:    and $1, $2, $8
4662; MIPS64ELR6-NEXT:    srlv $1, $1, $10
4663; MIPS64ELR6-NEXT:    seh $1, $1
4664; MIPS64ELR6-NEXT:  # %bb.3: # %entry
4665; MIPS64ELR6-NEXT:    sw $1, 12($sp) # 4-byte Folded Spill
4666; MIPS64ELR6-NEXT:  # %bb.4: # %entry
4667; MIPS64ELR6-NEXT:    lw $2, 12($sp) # 4-byte Folded Reload
4668; MIPS64ELR6-NEXT:    sync
4669; MIPS64ELR6-NEXT:    daddiu $sp, $sp, 16
4670; MIPS64ELR6-NEXT:    jrc $ra
4671entry:
4672  %0 = atomicrmw umin i8* %ptr, i8 %val seq_cst
4673  ret i8 %0
4674}
4675