xref: /llvm-project/llvm/test/CodeGen/VE/Scalar/umax.ll (revision 4cd1c0749143ce9e78a9cfe176a9fb7a5d34637f)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2; RUN: llc < %s -mtriple=ve | FileCheck %s
3
4;;; Test ‘llvm.umax.*’ intrinsic
5;;;
6;;; Syntax:
7;;;   This is an overloaded intrinsic. You can use @llvm.umax on any
8;;;   integer bit width or any vector of integer elements.
9;;;
10;;; declare i32 @llvm.umax.i32(i32 %a, i32 %b)
11;;; declare <4 x i32> @llvm.umax.v4i32(<4 x i32> %a, <4 x i32> %b)
12;;;
13;;; Overview:
14;;;   Return the larger of %a and %b comparing the values as unsigned
15;;;   integers. Vector intrinsics operate on a per-element basis. The
16;;;   larger element of %a and %b at a given index is returned for
17;;;   that index.
18;;;
19;;; Arguments:
20;;;   The arguments (%a and %b) may be of any integer type or a vector
21;;;   with integer element type. The argument types must match each
22;;;   other, and the return type must match the argument type.
23;;;
24;;; Note:
25;;;   We test only i1/u8/u16/u32/u64/u128.
26
27; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
28define zeroext i1 @func_umax_var_i1(i1 noundef zeroext %0, i1 noundef zeroext %1) {
29; CHECK-LABEL: func_umax_var_i1:
30; CHECK:       # %bb.0:
31; CHECK-NEXT:    or %s0, %s0, %s1
32; CHECK-NEXT:    b.l.t (, %s10)
33  %3 = tail call i1 @llvm.umax.i1(i1 %0, i1 %1)
34  ret i1 %3
35}
36
37; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
38define zeroext i8 @func_umax_var_u8(i8 noundef zeroext %0, i8 noundef zeroext %1) {
39; CHECK-LABEL: func_umax_var_u8:
40; CHECK:       # %bb.0:
41; CHECK-NEXT:    maxs.w.sx %s0, %s0, %s1
42; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
43; CHECK-NEXT:    b.l.t (, %s10)
44  %3 = tail call i8 @llvm.umax.i8(i8 %0, i8 %1)
45  ret i8 %3
46}
47
48; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
49define zeroext i16 @func_umax_var_u16(i16 noundef zeroext %0, i16 noundef zeroext %1) {
50; CHECK-LABEL: func_umax_var_u16:
51; CHECK:       # %bb.0:
52; CHECK-NEXT:    maxs.w.sx %s0, %s0, %s1
53; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
54; CHECK-NEXT:    b.l.t (, %s10)
55  %3 = tail call i16 @llvm.umax.i16(i16 %0, i16 %1)
56  ret i16 %3
57}
58
59; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
60define zeroext i32 @func_umax_var_u32(i32 noundef zeroext %0, i32 noundef zeroext %1) {
61; CHECK-LABEL: func_umax_var_u32:
62; CHECK:       # %bb.0:
63; CHECK-NEXT:    cmpu.w %s2, %s0, %s1
64; CHECK-NEXT:    cmov.w.gt %s1, %s0, %s2
65; CHECK-NEXT:    adds.w.zx %s0, %s1, (0)1
66; CHECK-NEXT:    b.l.t (, %s10)
67  %3 = tail call i32 @llvm.umax.i32(i32 %0, i32 %1)
68  ret i32 %3
69}
70
71; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
72define i64 @func_umax_var_u64(i64 noundef %0, i64 noundef %1) {
73; CHECK-LABEL: func_umax_var_u64:
74; CHECK:       # %bb.0:
75; CHECK-NEXT:    cmpu.l %s2, %s0, %s1
76; CHECK-NEXT:    cmov.l.gt %s1, %s0, %s2
77; CHECK-NEXT:    or %s0, 0, %s1
78; CHECK-NEXT:    b.l.t (, %s10)
79  %3 = tail call i64 @llvm.umax.i64(i64 %0, i64 %1)
80  ret i64 %3
81}
82
83; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
84define i128 @func_umax_var_u128(i128 noundef %0, i128 noundef %1) {
85; CHECK-LABEL: func_umax_var_u128:
86; CHECK:       # %bb.0:
87; CHECK-NEXT:    cmpu.l %s4, %s1, %s3
88; CHECK-NEXT:    or %s5, 0, (0)1
89; CHECK-NEXT:    or %s6, 0, (0)1
90; CHECK-NEXT:    cmov.l.gt %s6, (63)0, %s4
91; CHECK-NEXT:    cmpu.l %s7, %s0, %s2
92; CHECK-NEXT:    cmov.l.gt %s5, (63)0, %s7
93; CHECK-NEXT:    cmov.l.eq %s6, %s5, %s4
94; CHECK-NEXT:    cmov.w.ne %s2, %s0, %s6
95; CHECK-NEXT:    cmov.w.ne %s3, %s1, %s6
96; CHECK-NEXT:    or %s0, 0, %s2
97; CHECK-NEXT:    or %s1, 0, %s3
98; CHECK-NEXT:    b.l.t (, %s10)
99  %3 = tail call i128 @llvm.umax.i128(i128 %0, i128 %1)
100  ret i128 %3
101}
102
103; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
104define zeroext i1 @func_umax_fore_zero_i1(i1 noundef returned zeroext %0) {
105; CHECK-LABEL: func_umax_fore_zero_i1:
106; CHECK:       # %bb.0:
107; CHECK-NEXT:    b.l.t (, %s10)
108  ret i1 %0
109}
110
111; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
112define zeroext i8 @func_umax_fore_zero_u8(i8 noundef returned zeroext %0) {
113; CHECK-LABEL: func_umax_fore_zero_u8:
114; CHECK:       # %bb.0:
115; CHECK-NEXT:    b.l.t (, %s10)
116  ret i8 %0
117}
118
119; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
120define zeroext i16 @func_umax_fore_zero_u16(i16 noundef returned zeroext %0) {
121; CHECK-LABEL: func_umax_fore_zero_u16:
122; CHECK:       # %bb.0:
123; CHECK-NEXT:    b.l.t (, %s10)
124  ret i16 %0
125}
126
127; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
128define zeroext i32 @func_umax_fore_zero_u32(i32 noundef returned zeroext %0) {
129; CHECK-LABEL: func_umax_fore_zero_u32:
130; CHECK:       # %bb.0:
131; CHECK-NEXT:    b.l.t (, %s10)
132  ret i32 %0
133}
134
135; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
136define i64 @func_umax_fore_zero_u64(i64 noundef returned %0) {
137; CHECK-LABEL: func_umax_fore_zero_u64:
138; CHECK:       # %bb.0:
139; CHECK-NEXT:    b.l.t (, %s10)
140  ret i64 %0
141}
142
143; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
144define i128 @func_umax_fore_zero_u128(i128 noundef returned %0) {
145; CHECK-LABEL: func_umax_fore_zero_u128:
146; CHECK:       # %bb.0:
147; CHECK-NEXT:    b.l.t (, %s10)
148  ret i128 %0
149}
150
151; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
152define zeroext i1 @func_umax_back_zero_i1(i1 noundef returned zeroext %0) {
153; CHECK-LABEL: func_umax_back_zero_i1:
154; CHECK:       # %bb.0:
155; CHECK-NEXT:    b.l.t (, %s10)
156  ret i1 %0
157}
158
159; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
160define zeroext i8 @func_umax_back_zero_u8(i8 noundef returned zeroext %0) {
161; CHECK-LABEL: func_umax_back_zero_u8:
162; CHECK:       # %bb.0:
163; CHECK-NEXT:    b.l.t (, %s10)
164  ret i8 %0
165}
166
167; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
168define zeroext i16 @func_umax_back_zero_u16(i16 noundef returned zeroext %0) {
169; CHECK-LABEL: func_umax_back_zero_u16:
170; CHECK:       # %bb.0:
171; CHECK-NEXT:    b.l.t (, %s10)
172  ret i16 %0
173}
174
175; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
176define zeroext i32 @func_umax_back_zero_u32(i32 noundef returned zeroext %0) {
177; CHECK-LABEL: func_umax_back_zero_u32:
178; CHECK:       # %bb.0:
179; CHECK-NEXT:    b.l.t (, %s10)
180  ret i32 %0
181}
182
183; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
184define i64 @func_umax_back_zero_u64(i64 noundef returned %0) {
185; CHECK-LABEL: func_umax_back_zero_u64:
186; CHECK:       # %bb.0:
187; CHECK-NEXT:    b.l.t (, %s10)
188  ret i64 %0
189}
190
191; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
192define i128 @func_umax_back_zero_u128(i128 noundef returned %0) {
193; CHECK-LABEL: func_umax_back_zero_u128:
194; CHECK:       # %bb.0:
195; CHECK-NEXT:    b.l.t (, %s10)
196  ret i128 %0
197}
198
199; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
200define zeroext i1 @func_umax_fore_const_i1(i1 noundef zeroext %0) {
201; CHECK-LABEL: func_umax_fore_const_i1:
202; CHECK:       # %bb.0:
203; CHECK-NEXT:    or %s0, 1, (0)1
204; CHECK-NEXT:    b.l.t (, %s10)
205  ret i1 true
206}
207
208; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
209define zeroext i8 @func_umax_fore_const_u8(i8 noundef zeroext %0) {
210; CHECK-LABEL: func_umax_fore_const_u8:
211; CHECK:       # %bb.0:
212; CHECK-NEXT:    lea %s0, 255
213; CHECK-NEXT:    b.l.t (, %s10)
214  ret i8 -1
215}
216
217; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
218define zeroext i16 @func_umax_fore_const_u16(i16 noundef zeroext %0) {
219; CHECK-LABEL: func_umax_fore_const_u16:
220; CHECK:       # %bb.0:
221; CHECK-NEXT:    maxs.w.sx %s0, %s0, (56)0
222; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
223; CHECK-NEXT:    b.l.t (, %s10)
224  %2 = tail call i16 @llvm.umax.i16(i16 %0, i16 255)
225  ret i16 %2
226}
227
228; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
229define zeroext i32 @func_umax_fore_const_u32(i32 noundef zeroext %0) {
230; CHECK-LABEL: func_umax_fore_const_u32:
231; CHECK:       # %bb.0:
232; CHECK-NEXT:    cmpu.w %s1, %s0, (56)0
233; CHECK-NEXT:    cmov.w.le %s0, (56)0, %s1
234; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
235; CHECK-NEXT:    b.l.t (, %s10)
236  %2 = tail call i32 @llvm.umax.i32(i32 %0, i32 255)
237  ret i32 %2
238}
239
240; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
241define i64 @func_umax_fore_const_u64(i64 noundef %0) {
242; CHECK-LABEL: func_umax_fore_const_u64:
243; CHECK:       # %bb.0:
244; CHECK-NEXT:    cmpu.l %s1, %s0, (56)0
245; CHECK-NEXT:    cmov.l.le %s0, (56)0, %s1
246; CHECK-NEXT:    b.l.t (, %s10)
247  %2 = tail call i64 @llvm.umax.i64(i64 %0, i64 255)
248  ret i64 %2
249}
250
251; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
252define i128 @func_umax_fore_const_u128(i128 noundef %0) {
253; CHECK-LABEL: func_umax_fore_const_u128:
254; CHECK:       # %bb.0:
255; CHECK-NEXT:    or %s2, 0, %s0
256; CHECK-NEXT:    cmov.l.eq %s2, (56)0, %s1
257; CHECK-NEXT:    cmpu.l %s3, %s0, (56)0
258; CHECK-NEXT:    cmov.l.le %s0, (56)0, %s3
259; CHECK-NEXT:    cmov.l.eq %s2, %s0, %s1
260; CHECK-NEXT:    or %s0, 0, %s2
261; CHECK-NEXT:    b.l.t (, %s10)
262  %2 = tail call i128 @llvm.umax.i128(i128 %0, i128 255)
263  ret i128 %2
264}
265
266; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
267define zeroext i1 @func_umax_back_const_i1(i1 noundef zeroext %0) {
268; CHECK-LABEL: func_umax_back_const_i1:
269; CHECK:       # %bb.0:
270; CHECK-NEXT:    or %s0, 1, (0)1
271; CHECK-NEXT:    b.l.t (, %s10)
272  ret i1 true
273}
274
275; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
276define zeroext i8 @func_umax_back_const_u8(i8 noundef zeroext %0) {
277; CHECK-LABEL: func_umax_back_const_u8:
278; CHECK:       # %bb.0:
279; CHECK-NEXT:    lea %s0, 255
280; CHECK-NEXT:    b.l.t (, %s10)
281  ret i8 -1
282}
283
284; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
285define zeroext i16 @func_umax_back_const_u16(i16 noundef zeroext %0) {
286; CHECK-LABEL: func_umax_back_const_u16:
287; CHECK:       # %bb.0:
288; CHECK-NEXT:    maxs.w.sx %s0, %s0, (56)0
289; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
290; CHECK-NEXT:    b.l.t (, %s10)
291  %2 = tail call i16 @llvm.umax.i16(i16 %0, i16 255)
292  ret i16 %2
293}
294
295; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
296define zeroext i32 @func_umax_back_const_u32(i32 noundef zeroext %0) {
297; CHECK-LABEL: func_umax_back_const_u32:
298; CHECK:       # %bb.0:
299; CHECK-NEXT:    cmpu.w %s1, %s0, (56)0
300; CHECK-NEXT:    cmov.w.le %s0, (56)0, %s1
301; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
302; CHECK-NEXT:    b.l.t (, %s10)
303  %2 = tail call i32 @llvm.umax.i32(i32 %0, i32 255)
304  ret i32 %2
305}
306
307; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
308define i64 @func_umax_back_const_u64(i64 noundef %0) {
309; CHECK-LABEL: func_umax_back_const_u64:
310; CHECK:       # %bb.0:
311; CHECK-NEXT:    cmpu.l %s1, %s0, (56)0
312; CHECK-NEXT:    cmov.l.le %s0, (56)0, %s1
313; CHECK-NEXT:    b.l.t (, %s10)
314  %2 = tail call i64 @llvm.umax.i64(i64 %0, i64 255)
315  ret i64 %2
316}
317
318; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
319define i128 @func_umax_back_const_u128(i128 noundef %0) {
320; CHECK-LABEL: func_umax_back_const_u128:
321; CHECK:       # %bb.0:
322; CHECK-NEXT:    or %s2, 0, %s0
323; CHECK-NEXT:    cmov.l.eq %s2, (56)0, %s1
324; CHECK-NEXT:    cmpu.l %s3, %s0, (56)0
325; CHECK-NEXT:    cmov.l.le %s0, (56)0, %s3
326; CHECK-NEXT:    cmov.l.eq %s2, %s0, %s1
327; CHECK-NEXT:    or %s0, 0, %s2
328; CHECK-NEXT:    b.l.t (, %s10)
329  %2 = tail call i128 @llvm.umax.i128(i128 %0, i128 255)
330  ret i128 %2
331}
332
333; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
334declare i32 @llvm.umax.i32(i32, i32)
335
336; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
337declare i1 @llvm.umax.i1(i1, i1)
338
339; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
340declare i8 @llvm.umax.i8(i8, i8)
341
342; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
343declare i16 @llvm.umax.i16(i16, i16)
344
345; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
346declare i64 @llvm.umax.i64(i64, i64)
347
348; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
349declare i128 @llvm.umax.i128(i128, i128)
350