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.smax.*’ intrinsic
7 ;;; This is an overloaded intrinsic. You can use @llvm.smax on any
8 ;;; integer bit width or any vector of integer elements.
10 ;;; declare i32 @llvm.smax.i32(i32 %a, i32 %b)
11 ;;; declare <4 x i32> @llvm.smax.v4i32(<4 x i32> %a, <4 x i32> %b)
14 ;;; Return the larger of %a and %b comparing the values as signed
15 ;;; integers. Vector intrinsics operate on a per-element basis.
16 ;;; The larger element of %a and %b at a given index is returned
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 i8/i16/i32/i64/i128.
27 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
28 define signext i8 @func_smax_var_i8(i8 noundef signext %0, i8 noundef signext %1) {
29 ; CHECK-LABEL: func_smax_var_i8:
31 ; CHECK-NEXT: maxs.w.sx %s0, %s0, %s1
32 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
33 ; CHECK-NEXT: b.l.t (, %s10)
34 %3 = tail call i8 @llvm.smax.i8(i8 %0, i8 %1)
38 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
39 define signext i16 @func_smax_var_i16(i16 noundef signext %0, i16 noundef signext %1) {
40 ; CHECK-LABEL: func_smax_var_i16:
42 ; CHECK-NEXT: maxs.w.sx %s0, %s0, %s1
43 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
44 ; CHECK-NEXT: b.l.t (, %s10)
45 %3 = tail call i16 @llvm.smax.i16(i16 %0, i16 %1)
49 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
50 define signext i32 @func_smax_var_i32(i32 noundef signext %0, i32 noundef signext %1) {
51 ; CHECK-LABEL: func_smax_var_i32:
53 ; CHECK-NEXT: maxs.w.sx %s0, %s0, %s1
54 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
55 ; CHECK-NEXT: b.l.t (, %s10)
56 %3 = tail call i32 @llvm.smax.i32(i32 %0, i32 %1)
60 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
61 define i64 @func_smax_var_i64(i64 noundef %0, i64 noundef %1) {
62 ; CHECK-LABEL: func_smax_var_i64:
64 ; CHECK-NEXT: maxs.l %s0, %s0, %s1
65 ; CHECK-NEXT: b.l.t (, %s10)
66 %3 = tail call i64 @llvm.smax.i64(i64 %0, i64 %1)
70 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
71 define i128 @func_smax_var_i128(i128 noundef %0, i128 noundef %1) {
72 ; CHECK-LABEL: func_smax_var_i128:
74 ; CHECK-NEXT: cmpu.l %s4, %s1, %s3
75 ; CHECK-NEXT: cmps.l %s5, %s1, %s3
76 ; CHECK-NEXT: or %s6, 0, (0)1
77 ; CHECK-NEXT: or %s7, 0, (0)1
78 ; CHECK-NEXT: cmov.l.gt %s7, (63)0, %s5
79 ; CHECK-NEXT: cmpu.l %s5, %s0, %s2
80 ; CHECK-NEXT: cmov.l.gt %s6, (63)0, %s5
81 ; CHECK-NEXT: cmov.l.eq %s7, %s6, %s4
82 ; CHECK-NEXT: cmov.w.ne %s2, %s0, %s7
83 ; CHECK-NEXT: cmov.w.ne %s3, %s1, %s7
84 ; CHECK-NEXT: or %s0, 0, %s2
85 ; CHECK-NEXT: or %s1, 0, %s3
86 ; CHECK-NEXT: b.l.t (, %s10)
87 %3 = tail call i128 @llvm.smax.i128(i128 %0, i128 %1)
91 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
92 define signext i8 @func_smax_fore_zero_i8(i8 noundef signext %0) {
93 ; CHECK-LABEL: func_smax_fore_zero_i8:
95 ; CHECK-NEXT: maxs.w.sx %s0, 0, %s0
96 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
97 ; CHECK-NEXT: b.l.t (, %s10)
98 %2 = tail call i8 @llvm.smax.i8(i8 %0, i8 0)
102 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
103 define signext i16 @func_smax_fore_zero_i16(i16 noundef signext %0) {
104 ; CHECK-LABEL: func_smax_fore_zero_i16:
106 ; CHECK-NEXT: maxs.w.sx %s0, 0, %s0
107 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
108 ; CHECK-NEXT: b.l.t (, %s10)
109 %2 = tail call i16 @llvm.smax.i16(i16 %0, i16 0)
113 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
114 define signext i32 @func_smax_fore_zero_i32(i32 noundef signext %0) {
115 ; CHECK-LABEL: func_smax_fore_zero_i32:
117 ; CHECK-NEXT: maxs.w.sx %s0, 0, %s0
118 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
119 ; CHECK-NEXT: b.l.t (, %s10)
120 %2 = tail call i32 @llvm.smax.i32(i32 %0, i32 0)
124 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
125 define i64 @func_smax_fore_zero_i64(i64 noundef %0) {
126 ; CHECK-LABEL: func_smax_fore_zero_i64:
128 ; CHECK-NEXT: maxs.l %s0, 0, %s0
129 ; CHECK-NEXT: b.l.t (, %s10)
130 %2 = tail call i64 @llvm.smax.i64(i64 %0, i64 0)
134 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
135 define i128 @func_smax_fore_zero_i128(i128 noundef %0) {
136 ; CHECK-LABEL: func_smax_fore_zero_i128:
138 ; CHECK-NEXT: cmov.l.lt %s0, (0)1, %s1
139 ; CHECK-NEXT: maxs.l %s1, 0, %s1
140 ; CHECK-NEXT: b.l.t (, %s10)
141 %2 = tail call i128 @llvm.smax.i128(i128 %0, i128 0)
145 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
146 define signext i8 @func_smax_back_zero_i8(i8 noundef signext %0) {
147 ; CHECK-LABEL: func_smax_back_zero_i8:
149 ; CHECK-NEXT: maxs.w.sx %s0, 0, %s0
150 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
151 ; CHECK-NEXT: b.l.t (, %s10)
152 %2 = tail call i8 @llvm.smax.i8(i8 %0, i8 0)
156 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
157 define signext i16 @func_smax_back_zero_i16(i16 noundef signext %0) {
158 ; CHECK-LABEL: func_smax_back_zero_i16:
160 ; CHECK-NEXT: maxs.w.sx %s0, 0, %s0
161 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
162 ; CHECK-NEXT: b.l.t (, %s10)
163 %2 = tail call i16 @llvm.smax.i16(i16 %0, i16 0)
167 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
168 define signext i32 @func_smax_back_zero_i32(i32 noundef signext %0) {
169 ; CHECK-LABEL: func_smax_back_zero_i32:
171 ; CHECK-NEXT: maxs.w.sx %s0, 0, %s0
172 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
173 ; CHECK-NEXT: b.l.t (, %s10)
174 %2 = tail call i32 @llvm.smax.i32(i32 %0, i32 0)
178 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
179 define i64 @func_smax_back_zero_i64(i64 noundef %0) {
180 ; CHECK-LABEL: func_smax_back_zero_i64:
182 ; CHECK-NEXT: maxs.l %s0, 0, %s0
183 ; CHECK-NEXT: b.l.t (, %s10)
184 %2 = tail call i64 @llvm.smax.i64(i64 %0, i64 0)
188 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
189 define i128 @func_smax_back_zero_i128(i128 noundef %0) {
190 ; CHECK-LABEL: func_smax_back_zero_i128:
192 ; CHECK-NEXT: cmov.l.lt %s0, (0)1, %s1
193 ; CHECK-NEXT: maxs.l %s1, 0, %s1
194 ; CHECK-NEXT: b.l.t (, %s10)
195 %2 = tail call i128 @llvm.smax.i128(i128 %0, i128 0)
199 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
200 define signext i8 @func_smax_fore_const_i8(i8 noundef signext %0) {
201 ; CHECK-LABEL: func_smax_fore_const_i8:
203 ; CHECK-NEXT: maxs.w.sx %s0, -1, %s0
204 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
205 ; CHECK-NEXT: b.l.t (, %s10)
206 %2 = tail call i8 @llvm.smax.i8(i8 %0, i8 -1)
210 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
211 define signext i16 @func_smax_fore_const_i16(i16 noundef signext %0) {
212 ; CHECK-LABEL: func_smax_fore_const_i16:
214 ; CHECK-NEXT: maxs.w.sx %s0, %s0, (56)0
215 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
216 ; CHECK-NEXT: b.l.t (, %s10)
217 %2 = tail call i16 @llvm.smax.i16(i16 %0, i16 255)
221 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
222 define signext i32 @func_smax_fore_const_i32(i32 noundef signext %0) {
223 ; CHECK-LABEL: func_smax_fore_const_i32:
225 ; CHECK-NEXT: maxs.w.sx %s0, %s0, (56)0
226 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
227 ; CHECK-NEXT: b.l.t (, %s10)
228 %2 = tail call i32 @llvm.smax.i32(i32 %0, i32 255)
232 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
233 define i64 @func_smax_fore_const_i64(i64 noundef %0) {
234 ; CHECK-LABEL: func_smax_fore_const_i64:
236 ; CHECK-NEXT: maxs.l %s0, %s0, (56)0
237 ; CHECK-NEXT: b.l.t (, %s10)
238 %2 = tail call i64 @llvm.smax.i64(i64 %0, i64 255)
242 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
243 define i128 @func_smax_fore_const_i128(i128 noundef %0) {
244 ; CHECK-LABEL: func_smax_fore_const_i128:
246 ; CHECK-NEXT: or %s2, 0, (0)1
247 ; CHECK-NEXT: cmps.l %s3, %s1, (0)1
248 ; CHECK-NEXT: or %s4, 0, (0)1
249 ; CHECK-NEXT: cmov.l.gt %s4, (63)0, %s3
250 ; CHECK-NEXT: cmpu.l %s3, %s0, (56)0
251 ; CHECK-NEXT: cmov.l.gt %s2, (63)0, %s3
252 ; CHECK-NEXT: cmov.l.eq %s4, %s2, %s1
253 ; CHECK-NEXT: cmov.w.eq %s0, (56)0, %s4
254 ; CHECK-NEXT: cmov.w.eq %s1, (0)1, %s4
255 ; CHECK-NEXT: b.l.t (, %s10)
256 %2 = tail call i128 @llvm.smax.i128(i128 %0, i128 255)
260 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
261 define signext i8 @func_smax_back_const_i8(i8 noundef signext %0) {
262 ; CHECK-LABEL: func_smax_back_const_i8:
264 ; CHECK-NEXT: maxs.w.sx %s0, -1, %s0
265 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
266 ; CHECK-NEXT: b.l.t (, %s10)
267 %2 = tail call i8 @llvm.smax.i8(i8 %0, i8 -1)
271 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
272 define signext i16 @func_smax_back_const_i16(i16 noundef signext %0) {
273 ; CHECK-LABEL: func_smax_back_const_i16:
275 ; CHECK-NEXT: maxs.w.sx %s0, %s0, (56)0
276 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
277 ; CHECK-NEXT: b.l.t (, %s10)
278 %2 = tail call i16 @llvm.smax.i16(i16 %0, i16 255)
282 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
283 define signext i32 @func_smax_back_const_i32(i32 noundef signext %0) {
284 ; CHECK-LABEL: func_smax_back_const_i32:
286 ; CHECK-NEXT: maxs.w.sx %s0, %s0, (56)0
287 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
288 ; CHECK-NEXT: b.l.t (, %s10)
289 %2 = tail call i32 @llvm.smax.i32(i32 %0, i32 255)
293 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
294 define i64 @func_smax_back_const_i64(i64 noundef %0) {
295 ; CHECK-LABEL: func_smax_back_const_i64:
297 ; CHECK-NEXT: maxs.l %s0, %s0, (56)0
298 ; CHECK-NEXT: b.l.t (, %s10)
299 %2 = tail call i64 @llvm.smax.i64(i64 %0, i64 255)
303 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
304 define i128 @func_smax_back_const_i128(i128 noundef %0) {
305 ; CHECK-LABEL: func_smax_back_const_i128:
307 ; CHECK-NEXT: or %s2, 0, (0)1
308 ; CHECK-NEXT: cmps.l %s3, %s1, (0)1
309 ; CHECK-NEXT: or %s4, 0, (0)1
310 ; CHECK-NEXT: cmov.l.gt %s4, (63)0, %s3
311 ; CHECK-NEXT: cmpu.l %s3, %s0, (56)0
312 ; CHECK-NEXT: cmov.l.gt %s2, (63)0, %s3
313 ; CHECK-NEXT: cmov.l.eq %s4, %s2, %s1
314 ; CHECK-NEXT: cmov.w.eq %s0, (56)0, %s4
315 ; CHECK-NEXT: cmov.w.eq %s1, (0)1, %s4
316 ; CHECK-NEXT: b.l.t (, %s10)
317 %2 = tail call i128 @llvm.smax.i128(i128 %0, i128 255)
321 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
322 declare i32 @llvm.smax.i32(i32, i32)
324 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
325 declare i8 @llvm.smax.i8(i8, i8)
327 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
328 declare i16 @llvm.smax.i16(i16, i16)
330 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
331 declare i64 @llvm.smax.i64(i64, i64)
333 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
334 declare i128 @llvm.smax.i128(i128, i128)