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
4 ;;; Test ‘llvm.umax.*’ intrinsic
7 ;;; This is an overloaded intrinsic. You can use @llvm.umax on any
8 ;;; integer bit width or any vector of integer elements.
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)
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
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.
25 ;;; We test only i1/u8/u16/u32/u64/u128.
27 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
28 define zeroext i1 @func_umax_var_i1(i1 noundef zeroext %0, i1 noundef zeroext %1) {
29 ; CHECK-LABEL: func_umax_var_i1:
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)
37 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
38 define zeroext i8 @func_umax_var_u8(i8 noundef zeroext %0, i8 noundef zeroext %1) {
39 ; CHECK-LABEL: func_umax_var_u8:
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)
48 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
49 define zeroext i16 @func_umax_var_u16(i16 noundef zeroext %0, i16 noundef zeroext %1) {
50 ; CHECK-LABEL: func_umax_var_u16:
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)
59 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
60 define zeroext i32 @func_umax_var_u32(i32 noundef zeroext %0, i32 noundef zeroext %1) {
61 ; CHECK-LABEL: func_umax_var_u32:
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)
71 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
72 define i64 @func_umax_var_u64(i64 noundef %0, i64 noundef %1) {
73 ; CHECK-LABEL: func_umax_var_u64:
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)
83 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
84 define i128 @func_umax_var_u128(i128 noundef %0, i128 noundef %1) {
85 ; CHECK-LABEL: func_umax_var_u128:
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)
103 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
104 define zeroext i1 @func_umax_fore_zero_i1(i1 noundef returned zeroext %0) {
105 ; CHECK-LABEL: func_umax_fore_zero_i1:
107 ; CHECK-NEXT: b.l.t (, %s10)
111 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
112 define zeroext i8 @func_umax_fore_zero_u8(i8 noundef returned zeroext %0) {
113 ; CHECK-LABEL: func_umax_fore_zero_u8:
115 ; CHECK-NEXT: b.l.t (, %s10)
119 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
120 define zeroext i16 @func_umax_fore_zero_u16(i16 noundef returned zeroext %0) {
121 ; CHECK-LABEL: func_umax_fore_zero_u16:
123 ; CHECK-NEXT: b.l.t (, %s10)
127 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
128 define zeroext i32 @func_umax_fore_zero_u32(i32 noundef returned zeroext %0) {
129 ; CHECK-LABEL: func_umax_fore_zero_u32:
131 ; CHECK-NEXT: b.l.t (, %s10)
135 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
136 define i64 @func_umax_fore_zero_u64(i64 noundef returned %0) {
137 ; CHECK-LABEL: func_umax_fore_zero_u64:
139 ; CHECK-NEXT: b.l.t (, %s10)
143 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
144 define i128 @func_umax_fore_zero_u128(i128 noundef returned %0) {
145 ; CHECK-LABEL: func_umax_fore_zero_u128:
147 ; CHECK-NEXT: b.l.t (, %s10)
151 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
152 define zeroext i1 @func_umax_back_zero_i1(i1 noundef returned zeroext %0) {
153 ; CHECK-LABEL: func_umax_back_zero_i1:
155 ; CHECK-NEXT: b.l.t (, %s10)
159 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
160 define zeroext i8 @func_umax_back_zero_u8(i8 noundef returned zeroext %0) {
161 ; CHECK-LABEL: func_umax_back_zero_u8:
163 ; CHECK-NEXT: b.l.t (, %s10)
167 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
168 define zeroext i16 @func_umax_back_zero_u16(i16 noundef returned zeroext %0) {
169 ; CHECK-LABEL: func_umax_back_zero_u16:
171 ; CHECK-NEXT: b.l.t (, %s10)
175 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
176 define zeroext i32 @func_umax_back_zero_u32(i32 noundef returned zeroext %0) {
177 ; CHECK-LABEL: func_umax_back_zero_u32:
179 ; CHECK-NEXT: b.l.t (, %s10)
183 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
184 define i64 @func_umax_back_zero_u64(i64 noundef returned %0) {
185 ; CHECK-LABEL: func_umax_back_zero_u64:
187 ; CHECK-NEXT: b.l.t (, %s10)
191 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
192 define i128 @func_umax_back_zero_u128(i128 noundef returned %0) {
193 ; CHECK-LABEL: func_umax_back_zero_u128:
195 ; CHECK-NEXT: b.l.t (, %s10)
199 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
200 define zeroext i1 @func_umax_fore_const_i1(i1 noundef zeroext %0) {
201 ; CHECK-LABEL: func_umax_fore_const_i1:
203 ; CHECK-NEXT: or %s0, 1, (0)1
204 ; CHECK-NEXT: b.l.t (, %s10)
208 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
209 define zeroext i8 @func_umax_fore_const_u8(i8 noundef zeroext %0) {
210 ; CHECK-LABEL: func_umax_fore_const_u8:
212 ; CHECK-NEXT: lea %s0, 255
213 ; CHECK-NEXT: b.l.t (, %s10)
217 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
218 define zeroext i16 @func_umax_fore_const_u16(i16 noundef zeroext %0) {
219 ; CHECK-LABEL: func_umax_fore_const_u16:
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)
228 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
229 define zeroext i32 @func_umax_fore_const_u32(i32 noundef zeroext %0) {
230 ; CHECK-LABEL: func_umax_fore_const_u32:
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)
240 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
241 define i64 @func_umax_fore_const_u64(i64 noundef %0) {
242 ; CHECK-LABEL: func_umax_fore_const_u64:
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)
251 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
252 define i128 @func_umax_fore_const_u128(i128 noundef %0) {
253 ; CHECK-LABEL: func_umax_fore_const_u128:
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)
266 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
267 define zeroext i1 @func_umax_back_const_i1(i1 noundef zeroext %0) {
268 ; CHECK-LABEL: func_umax_back_const_i1:
270 ; CHECK-NEXT: or %s0, 1, (0)1
271 ; CHECK-NEXT: b.l.t (, %s10)
275 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
276 define zeroext i8 @func_umax_back_const_u8(i8 noundef zeroext %0) {
277 ; CHECK-LABEL: func_umax_back_const_u8:
279 ; CHECK-NEXT: lea %s0, 255
280 ; CHECK-NEXT: b.l.t (, %s10)
284 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
285 define zeroext i16 @func_umax_back_const_u16(i16 noundef zeroext %0) {
286 ; CHECK-LABEL: func_umax_back_const_u16:
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)
295 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
296 define zeroext i32 @func_umax_back_const_u32(i32 noundef zeroext %0) {
297 ; CHECK-LABEL: func_umax_back_const_u32:
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)
307 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
308 define i64 @func_umax_back_const_u64(i64 noundef %0) {
309 ; CHECK-LABEL: func_umax_back_const_u64:
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)
318 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
319 define i128 @func_umax_back_const_u128(i128 noundef %0) {
320 ; CHECK-LABEL: func_umax_back_const_u128:
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)
333 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
334 declare i32 @llvm.umax.i32(i32, i32)
336 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
337 declare i1 @llvm.umax.i1(i1, i1)
339 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
340 declare i8 @llvm.umax.i8(i8, i8)
342 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
343 declare i16 @llvm.umax.i16(i16, i16)
345 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
346 declare i64 @llvm.umax.i64(i64, i64)
348 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
349 declare i128 @llvm.umax.i128(i128, i128)