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