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.smin.*’ intrinsic
7 ;;; This is an overloaded intrinsic. You can use @llvm.smin on any
8 ;;; integer bit width or any vector of integer elements.
10 ;;; declare i32 @llvm.smin.i32(i32 %a, i32 %b)
11 ;;; declare <4 x i32> @llvm.smin.v4i32(<4 x i32> %a, <4 x i32> %b)
14 ;;; Return the smaller of %a and %b comparing the values as signed
15 ;;; integers. Vector intrinsics operate on a per-element basis.
16 ;;; The smaller 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_smin_var_i8(i8 noundef signext %0, i8 noundef signext %1) {
29 ; CHECK-LABEL: func_smin_var_i8:
31 ; CHECK-NEXT: mins.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.smin.i8(i8 %0, i8 %1)
38 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
39 define signext i16 @func_smin_var_i16(i16 noundef signext %0, i16 noundef signext %1) {
40 ; CHECK-LABEL: func_smin_var_i16:
42 ; CHECK-NEXT: mins.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.smin.i16(i16 %0, i16 %1)
49 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
50 define signext i32 @func_smin_var_i32(i32 noundef signext %0, i32 noundef signext %1) {
51 ; CHECK-LABEL: func_smin_var_i32:
53 ; CHECK-NEXT: mins.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.smin.i32(i32 %0, i32 %1)
60 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
61 define i64 @func_smin_var_i64(i64 noundef %0, i64 noundef %1) {
62 ; CHECK-LABEL: func_smin_var_i64:
64 ; CHECK-NEXT: mins.l %s0, %s0, %s1
65 ; CHECK-NEXT: b.l.t (, %s10)
66 %3 = tail call i64 @llvm.smin.i64(i64 %0, i64 %1)
70 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
71 define i128 @func_smin_var_i128(i128 noundef %0, i128 noundef %1) {
72 ; CHECK-LABEL: func_smin_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.lt %s7, (63)0, %s5
79 ; CHECK-NEXT: cmpu.l %s5, %s0, %s2
80 ; CHECK-NEXT: cmov.l.lt %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.smin.i128(i128 %0, i128 %1)
91 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
92 define signext i8 @func_smin_fore_zero_i8(i8 noundef signext %0) {
93 ; CHECK-LABEL: func_smin_fore_zero_i8:
95 ; CHECK-NEXT: mins.w.sx %s0, 0, %s0
96 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
97 ; CHECK-NEXT: b.l.t (, %s10)
98 %2 = tail call i8 @llvm.smin.i8(i8 %0, i8 0)
102 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
103 define signext i16 @func_smin_fore_zero_i16(i16 noundef signext %0) {
104 ; CHECK-LABEL: func_smin_fore_zero_i16:
106 ; CHECK-NEXT: mins.w.sx %s0, 0, %s0
107 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
108 ; CHECK-NEXT: b.l.t (, %s10)
109 %2 = tail call i16 @llvm.smin.i16(i16 %0, i16 0)
113 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
114 define signext i32 @func_smin_fore_zero_i32(i32 noundef signext %0) {
115 ; CHECK-LABEL: func_smin_fore_zero_i32:
117 ; CHECK-NEXT: mins.w.sx %s0, 0, %s0
118 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
119 ; CHECK-NEXT: b.l.t (, %s10)
120 %2 = tail call i32 @llvm.smin.i32(i32 %0, i32 0)
124 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
125 define i64 @func_smin_fore_zero_i64(i64 noundef %0) {
126 ; CHECK-LABEL: func_smin_fore_zero_i64:
128 ; CHECK-NEXT: mins.l %s0, 0, %s0
129 ; CHECK-NEXT: b.l.t (, %s10)
130 %2 = tail call i64 @llvm.smin.i64(i64 %0, i64 0)
134 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
135 define i128 @func_smin_fore_zero_i128(i128 noundef %0) {
136 ; CHECK-LABEL: func_smin_fore_zero_i128:
138 ; CHECK-NEXT: sra.l %s2, %s1, 63
139 ; CHECK-NEXT: and %s0, %s2, %s0
140 ; CHECK-NEXT: and %s1, %s2, %s1
141 ; CHECK-NEXT: b.l.t (, %s10)
142 %2 = tail call i128 @llvm.smin.i128(i128 %0, i128 0)
146 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
147 define signext i8 @func_smin_back_zero_i8(i8 noundef signext %0) {
148 ; CHECK-LABEL: func_smin_back_zero_i8:
150 ; CHECK-NEXT: mins.w.sx %s0, 0, %s0
151 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
152 ; CHECK-NEXT: b.l.t (, %s10)
153 %2 = tail call i8 @llvm.smin.i8(i8 %0, i8 0)
157 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
158 define signext i16 @func_smin_back_zero_i16(i16 noundef signext %0) {
159 ; CHECK-LABEL: func_smin_back_zero_i16:
161 ; CHECK-NEXT: mins.w.sx %s0, 0, %s0
162 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
163 ; CHECK-NEXT: b.l.t (, %s10)
164 %2 = tail call i16 @llvm.smin.i16(i16 %0, i16 0)
168 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
169 define signext i32 @func_smin_back_zero_i32(i32 noundef signext %0) {
170 ; CHECK-LABEL: func_smin_back_zero_i32:
172 ; CHECK-NEXT: mins.w.sx %s0, 0, %s0
173 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
174 ; CHECK-NEXT: b.l.t (, %s10)
175 %2 = tail call i32 @llvm.smin.i32(i32 %0, i32 0)
179 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
180 define i64 @func_smin_back_zero_i64(i64 noundef %0) {
181 ; CHECK-LABEL: func_smin_back_zero_i64:
183 ; CHECK-NEXT: mins.l %s0, 0, %s0
184 ; CHECK-NEXT: b.l.t (, %s10)
185 %2 = tail call i64 @llvm.smin.i64(i64 %0, i64 0)
189 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
190 define i128 @func_smin_back_zero_i128(i128 noundef %0) {
191 ; CHECK-LABEL: func_smin_back_zero_i128:
193 ; CHECK-NEXT: sra.l %s2, %s1, 63
194 ; CHECK-NEXT: and %s0, %s2, %s0
195 ; CHECK-NEXT: and %s1, %s2, %s1
196 ; CHECK-NEXT: b.l.t (, %s10)
197 %2 = tail call i128 @llvm.smin.i128(i128 %0, i128 0)
201 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
202 define signext i8 @func_smin_fore_const_i8(i8 noundef signext %0) {
203 ; CHECK-LABEL: func_smin_fore_const_i8:
205 ; CHECK-NEXT: mins.w.sx %s0, -1, %s0
206 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
207 ; CHECK-NEXT: b.l.t (, %s10)
208 %2 = tail call i8 @llvm.smin.i8(i8 %0, i8 -1)
212 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
213 define signext i16 @func_smin_fore_const_i16(i16 noundef signext %0) {
214 ; CHECK-LABEL: func_smin_fore_const_i16:
216 ; CHECK-NEXT: mins.w.sx %s0, %s0, (56)0
217 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
218 ; CHECK-NEXT: b.l.t (, %s10)
219 %2 = tail call i16 @llvm.smin.i16(i16 %0, i16 255)
223 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
224 define signext i32 @func_smin_fore_const_i32(i32 noundef signext %0) {
225 ; CHECK-LABEL: func_smin_fore_const_i32:
227 ; CHECK-NEXT: mins.w.sx %s0, %s0, (56)0
228 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
229 ; CHECK-NEXT: b.l.t (, %s10)
230 %2 = tail call i32 @llvm.smin.i32(i32 %0, i32 255)
234 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
235 define i64 @func_smin_fore_const_i64(i64 noundef %0) {
236 ; CHECK-LABEL: func_smin_fore_const_i64:
238 ; CHECK-NEXT: mins.l %s0, %s0, (56)0
239 ; CHECK-NEXT: b.l.t (, %s10)
240 %2 = tail call i64 @llvm.smin.i64(i64 %0, i64 255)
244 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
245 define i128 @func_smin_fore_const_i128(i128 noundef %0) {
246 ; CHECK-LABEL: func_smin_fore_const_i128:
248 ; CHECK-NEXT: or %s2, 0, (0)1
249 ; CHECK-NEXT: cmps.l %s3, %s1, (0)1
250 ; CHECK-NEXT: or %s4, 0, (0)1
251 ; CHECK-NEXT: cmov.l.lt %s4, (63)0, %s3
252 ; CHECK-NEXT: cmpu.l %s3, %s0, (56)0
253 ; CHECK-NEXT: cmov.l.lt %s2, (63)0, %s3
254 ; CHECK-NEXT: cmov.l.eq %s4, %s2, %s1
255 ; CHECK-NEXT: cmov.w.eq %s0, (56)0, %s4
256 ; CHECK-NEXT: cmov.w.eq %s1, (0)1, %s4
257 ; CHECK-NEXT: b.l.t (, %s10)
258 %2 = tail call i128 @llvm.smin.i128(i128 %0, i128 255)
262 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
263 define signext i8 @func_smin_back_const_i8(i8 noundef signext %0) {
264 ; CHECK-LABEL: func_smin_back_const_i8:
266 ; CHECK-NEXT: mins.w.sx %s0, -1, %s0
267 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
268 ; CHECK-NEXT: b.l.t (, %s10)
269 %2 = tail call i8 @llvm.smin.i8(i8 %0, i8 -1)
273 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
274 define signext i16 @func_smin_back_const_i16(i16 noundef signext %0) {
275 ; CHECK-LABEL: func_smin_back_const_i16:
277 ; CHECK-NEXT: mins.w.sx %s0, %s0, (56)0
278 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
279 ; CHECK-NEXT: b.l.t (, %s10)
280 %2 = tail call i16 @llvm.smin.i16(i16 %0, i16 255)
284 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
285 define signext i32 @func_smin_back_const_i32(i32 noundef signext %0) {
286 ; CHECK-LABEL: func_smin_back_const_i32:
288 ; CHECK-NEXT: mins.w.sx %s0, %s0, (56)0
289 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
290 ; CHECK-NEXT: b.l.t (, %s10)
291 %2 = tail call i32 @llvm.smin.i32(i32 %0, i32 255)
295 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
296 define i64 @func_smin_back_const_i64(i64 noundef %0) {
297 ; CHECK-LABEL: func_smin_back_const_i64:
299 ; CHECK-NEXT: mins.l %s0, %s0, (56)0
300 ; CHECK-NEXT: b.l.t (, %s10)
301 %2 = tail call i64 @llvm.smin.i64(i64 %0, i64 255)
305 ; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
306 define i128 @func_smin_back_const_i128(i128 noundef %0) {
307 ; CHECK-LABEL: func_smin_back_const_i128:
309 ; CHECK-NEXT: or %s2, 0, (0)1
310 ; CHECK-NEXT: cmps.l %s3, %s1, (0)1
311 ; CHECK-NEXT: or %s4, 0, (0)1
312 ; CHECK-NEXT: cmov.l.lt %s4, (63)0, %s3
313 ; CHECK-NEXT: cmpu.l %s3, %s0, (56)0
314 ; CHECK-NEXT: cmov.l.lt %s2, (63)0, %s3
315 ; CHECK-NEXT: cmov.l.eq %s4, %s2, %s1
316 ; CHECK-NEXT: cmov.w.eq %s0, (56)0, %s4
317 ; CHECK-NEXT: cmov.w.eq %s1, (0)1, %s4
318 ; CHECK-NEXT: b.l.t (, %s10)
319 %2 = tail call i128 @llvm.smin.i128(i128 %0, i128 255)
323 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
324 declare i32 @llvm.smin.i32(i32, i32)
326 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
327 declare i8 @llvm.smin.i8(i8, i8)
329 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
330 declare i16 @llvm.smin.i16(i16, i16)
332 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
333 declare i64 @llvm.smin.i64(i64, i64)
335 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
336 declare i128 @llvm.smin.i128(i128, i128)