1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+d,+zfh,+zvfh,+v -target-abi=ilp32d \
3 ; RUN: -verify-machineinstrs < %s | FileCheck %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+zvfh,+v -target-abi=lp64d \
5 ; RUN: -verify-machineinstrs < %s | FileCheck %s
9 declare <vscale x 2 x i32> @llvm.fptosi.sat.nxv2f32.nxv2i32(<vscale x 2 x float>)
10 declare <vscale x 4 x i32> @llvm.fptosi.sat.nxv4f32.nxv4i32(<vscale x 4 x float>)
11 declare <vscale x 8 x i32> @llvm.fptosi.sat.nxv8f32.nxv8i32(<vscale x 8 x float>)
12 declare <vscale x 4 x i16> @llvm.fptosi.sat.nxv4f32.nxv4i16(<vscale x 4 x float>)
13 declare <vscale x 8 x i16> @llvm.fptosi.sat.nxv8f32.nxv8i16(<vscale x 8 x float>)
14 declare <vscale x 2 x i64> @llvm.fptosi.sat.nxv2f32.nxv2i64(<vscale x 2 x float>)
15 declare <vscale x 4 x i64> @llvm.fptosi.sat.nxv4f32.nxv4i64(<vscale x 4 x float>)
17 define <vscale x 2 x i32> @test_signed_v2f32_v2i32(<vscale x 2 x float> %f) {
18 ; CHECK-LABEL: test_signed_v2f32_v2i32:
20 ; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, ma
21 ; CHECK-NEXT: vmfne.vv v0, v8, v8
22 ; CHECK-NEXT: vfcvt.rtz.x.f.v v8, v8
23 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
25 %x = call <vscale x 2 x i32> @llvm.fptosi.sat.nxv2f32.nxv2i32(<vscale x 2 x float> %f)
26 ret <vscale x 2 x i32> %x
29 define <vscale x 4 x i32> @test_signed_v4f32_v4i32(<vscale x 4 x float> %f) {
30 ; CHECK-LABEL: test_signed_v4f32_v4i32:
32 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
33 ; CHECK-NEXT: vmfne.vv v0, v8, v8
34 ; CHECK-NEXT: vfcvt.rtz.x.f.v v8, v8
35 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
37 %x = call <vscale x 4 x i32> @llvm.fptosi.sat.nxv4f32.nxv4i32(<vscale x 4 x float> %f)
38 ret <vscale x 4 x i32> %x
41 define <vscale x 8 x i32> @test_signed_v8f32_v8i32(<vscale x 8 x float> %f) {
42 ; CHECK-LABEL: test_signed_v8f32_v8i32:
44 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
45 ; CHECK-NEXT: vmfne.vv v0, v8, v8
46 ; CHECK-NEXT: vfcvt.rtz.x.f.v v8, v8
47 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
49 %x = call <vscale x 8 x i32> @llvm.fptosi.sat.nxv8f32.nxv8i32(<vscale x 8 x float> %f)
50 ret <vscale x 8 x i32> %x
53 define <vscale x 4 x i16> @test_signed_v4f32_v4i16(<vscale x 4 x float> %f) {
54 ; CHECK-LABEL: test_signed_v4f32_v4i16:
56 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
57 ; CHECK-NEXT: vmfne.vv v0, v8, v8
58 ; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, ma
59 ; CHECK-NEXT: vfncvt.rtz.x.f.w v10, v8
60 ; CHECK-NEXT: vmerge.vim v8, v10, 0, v0
62 %x = call <vscale x 4 x i16> @llvm.fptosi.sat.nxv4f32.nxv4i16(<vscale x 4 x float> %f)
63 ret <vscale x 4 x i16> %x
66 define <vscale x 8 x i16> @test_signed_v8f32_v8i16(<vscale x 8 x float> %f) {
67 ; CHECK-LABEL: test_signed_v8f32_v8i16:
69 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
70 ; CHECK-NEXT: vmfne.vv v0, v8, v8
71 ; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, ma
72 ; CHECK-NEXT: vfncvt.rtz.x.f.w v12, v8
73 ; CHECK-NEXT: vmerge.vim v8, v12, 0, v0
75 %x = call <vscale x 8 x i16> @llvm.fptosi.sat.nxv8f32.nxv8i16(<vscale x 8 x float> %f)
76 ret <vscale x 8 x i16> %x
79 define <vscale x 2 x i64> @test_signed_v2f32_v2i64(<vscale x 2 x float> %f) {
80 ; CHECK-LABEL: test_signed_v2f32_v2i64:
82 ; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, ma
83 ; CHECK-NEXT: vmfne.vv v0, v8, v8
84 ; CHECK-NEXT: vfwcvt.rtz.x.f.v v10, v8
85 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma
86 ; CHECK-NEXT: vmerge.vim v8, v10, 0, v0
88 %x = call <vscale x 2 x i64> @llvm.fptosi.sat.nxv2f32.nxv2i64(<vscale x 2 x float> %f)
89 ret <vscale x 2 x i64> %x
92 define <vscale x 4 x i64> @test_signed_v4f32_v4i64(<vscale x 4 x float> %f) {
93 ; CHECK-LABEL: test_signed_v4f32_v4i64:
95 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
96 ; CHECK-NEXT: vmfne.vv v0, v8, v8
97 ; CHECK-NEXT: vfwcvt.rtz.x.f.v v12, v8
98 ; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma
99 ; CHECK-NEXT: vmerge.vim v8, v12, 0, v0
101 %x = call <vscale x 4 x i64> @llvm.fptosi.sat.nxv4f32.nxv4i64(<vscale x 4 x float> %f)
102 ret <vscale x 4 x i64> %x
107 declare <vscale x 2 x i32> @llvm.fptosi.sat.nxv2f64.nxv2i32(<vscale x 2 x double>)
108 declare <vscale x 4 x i32> @llvm.fptosi.sat.nxv4f64.nxv4i32(<vscale x 4 x double>)
109 declare <vscale x 8 x i32> @llvm.fptosi.sat.nxv8f64.nxv8i32(<vscale x 8 x double>)
110 declare <vscale x 4 x i16> @llvm.fptosi.sat.nxv4f64.nxv4i16(<vscale x 4 x double>)
111 declare <vscale x 8 x i16> @llvm.fptosi.sat.nxv8f64.nxv8i16(<vscale x 8 x double>)
112 declare <vscale x 2 x i64> @llvm.fptosi.sat.nxv2f64.nxv2i64(<vscale x 2 x double>)
113 declare <vscale x 4 x i64> @llvm.fptosi.sat.nxv4f64.nxv4i64(<vscale x 4 x double>)
115 define <vscale x 2 x i32> @test_signed_v2f64_v2i32(<vscale x 2 x double> %f) {
116 ; CHECK-LABEL: test_signed_v2f64_v2i32:
118 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
119 ; CHECK-NEXT: vmfne.vv v0, v8, v8
120 ; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma
121 ; CHECK-NEXT: vfncvt.rtz.x.f.w v10, v8
122 ; CHECK-NEXT: vmerge.vim v8, v10, 0, v0
124 %x = call <vscale x 2 x i32> @llvm.fptosi.sat.nxv2f64.nxv2i32(<vscale x 2 x double> %f)
125 ret <vscale x 2 x i32> %x
128 define <vscale x 4 x i32> @test_signed_v4f64_v4i32(<vscale x 4 x double> %f) {
129 ; CHECK-LABEL: test_signed_v4f64_v4i32:
131 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
132 ; CHECK-NEXT: vmfne.vv v0, v8, v8
133 ; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma
134 ; CHECK-NEXT: vfncvt.rtz.x.f.w v12, v8
135 ; CHECK-NEXT: vmerge.vim v8, v12, 0, v0
137 %x = call <vscale x 4 x i32> @llvm.fptosi.sat.nxv4f64.nxv4i32(<vscale x 4 x double> %f)
138 ret <vscale x 4 x i32> %x
141 define <vscale x 8 x i32> @test_signed_v8f64_v8i32(<vscale x 8 x double> %f) {
142 ; CHECK-LABEL: test_signed_v8f64_v8i32:
144 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
145 ; CHECK-NEXT: vmfne.vv v0, v8, v8
146 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
147 ; CHECK-NEXT: vfncvt.rtz.x.f.w v16, v8
148 ; CHECK-NEXT: vmerge.vim v8, v16, 0, v0
150 %x = call <vscale x 8 x i32> @llvm.fptosi.sat.nxv8f64.nxv8i32(<vscale x 8 x double> %f)
151 ret <vscale x 8 x i32> %x
154 define <vscale x 4 x i16> @test_signed_v4f64_v4i16(<vscale x 4 x double> %f) {
155 ; CHECK-LABEL: test_signed_v4f64_v4i16:
157 ; CHECK-NEXT: lui a0, %hi(.LCPI10_0)
158 ; CHECK-NEXT: fld fa5, %lo(.LCPI10_0)(a0)
159 ; CHECK-NEXT: lui a0, %hi(.LCPI10_1)
160 ; CHECK-NEXT: fld fa4, %lo(.LCPI10_1)(a0)
161 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
162 ; CHECK-NEXT: vfmax.vf v12, v8, fa5
163 ; CHECK-NEXT: vfmin.vf v12, v12, fa4
164 ; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma
165 ; CHECK-NEXT: vfncvt.rtz.x.f.w v16, v12
166 ; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, ma
167 ; CHECK-NEXT: vnsrl.wi v12, v16, 0
168 ; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma
169 ; CHECK-NEXT: vmfne.vv v0, v8, v8
170 ; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, ma
171 ; CHECK-NEXT: vmerge.vim v8, v12, 0, v0
173 %x = call <vscale x 4 x i16> @llvm.fptosi.sat.nxv4f64.nxv4i16(<vscale x 4 x double> %f)
174 ret <vscale x 4 x i16> %x
177 define <vscale x 8 x i16> @test_signed_v8f64_v8i16(<vscale x 8 x double> %f) {
178 ; CHECK-LABEL: test_signed_v8f64_v8i16:
180 ; CHECK-NEXT: lui a0, %hi(.LCPI11_0)
181 ; CHECK-NEXT: fld fa5, %lo(.LCPI11_0)(a0)
182 ; CHECK-NEXT: lui a0, %hi(.LCPI11_1)
183 ; CHECK-NEXT: fld fa4, %lo(.LCPI11_1)(a0)
184 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
185 ; CHECK-NEXT: vfmax.vf v16, v8, fa5
186 ; CHECK-NEXT: vfmin.vf v16, v16, fa4
187 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
188 ; CHECK-NEXT: vfncvt.rtz.x.f.w v24, v16
189 ; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, ma
190 ; CHECK-NEXT: vnsrl.wi v16, v24, 0
191 ; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma
192 ; CHECK-NEXT: vmfne.vv v0, v8, v8
193 ; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, ma
194 ; CHECK-NEXT: vmerge.vim v8, v16, 0, v0
196 %x = call <vscale x 8 x i16> @llvm.fptosi.sat.nxv8f64.nxv8i16(<vscale x 8 x double> %f)
197 ret <vscale x 8 x i16> %x
200 define <vscale x 2 x i64> @test_signed_v2f64_v2i64(<vscale x 2 x double> %f) {
201 ; CHECK-LABEL: test_signed_v2f64_v2i64:
203 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
204 ; CHECK-NEXT: vmfne.vv v0, v8, v8
205 ; CHECK-NEXT: vfcvt.rtz.x.f.v v8, v8
206 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
208 %x = call <vscale x 2 x i64> @llvm.fptosi.sat.nxv2f64.nxv2i64(<vscale x 2 x double> %f)
209 ret <vscale x 2 x i64> %x
212 define <vscale x 4 x i64> @test_signed_v4f64_v4i64(<vscale x 4 x double> %f) {
213 ; CHECK-LABEL: test_signed_v4f64_v4i64:
215 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
216 ; CHECK-NEXT: vmfne.vv v0, v8, v8
217 ; CHECK-NEXT: vfcvt.rtz.x.f.v v8, v8
218 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
220 %x = call <vscale x 4 x i64> @llvm.fptosi.sat.nxv4f64.nxv4i64(<vscale x 4 x double> %f)
221 ret <vscale x 4 x i64> %x
227 declare <vscale x 2 x i32> @llvm.fptosi.sat.nxv2f16.nxv2i32(<vscale x 2 x half>)
228 declare <vscale x 4 x i32> @llvm.fptosi.sat.nxv4f16.nxv4i32(<vscale x 4 x half>)
229 declare <vscale x 8 x i32> @llvm.fptosi.sat.nxv8f16.nxv8i32(<vscale x 8 x half>)
230 declare <vscale x 4 x i16> @llvm.fptosi.sat.nxv4f16.nxv4i16(<vscale x 4 x half>)
231 declare <vscale x 8 x i16> @llvm.fptosi.sat.nxv8f16.nxv8i16(<vscale x 8 x half>)
232 declare <vscale x 2 x i64> @llvm.fptosi.sat.nxv2f16.nxv2i64(<vscale x 2 x half>)
233 declare <vscale x 4 x i64> @llvm.fptosi.sat.nxv4f16.nxv4i64(<vscale x 4 x half>)
235 define <vscale x 2 x i32> @test_signed_v2f16_v2i32(<vscale x 2 x half> %f) {
236 ; CHECK-LABEL: test_signed_v2f16_v2i32:
238 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
239 ; CHECK-NEXT: vmfne.vv v0, v8, v8
240 ; CHECK-NEXT: vfwcvt.rtz.x.f.v v9, v8
241 ; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma
242 ; CHECK-NEXT: vmerge.vim v8, v9, 0, v0
244 %x = call <vscale x 2 x i32> @llvm.fptosi.sat.nxv2f16.nxv2i32(<vscale x 2 x half> %f)
245 ret <vscale x 2 x i32> %x
248 define <vscale x 4 x i32> @test_signed_v4f16_v4i32(<vscale x 4 x half> %f) {
249 ; CHECK-LABEL: test_signed_v4f16_v4i32:
251 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
252 ; CHECK-NEXT: vmfne.vv v0, v8, v8
253 ; CHECK-NEXT: vfwcvt.rtz.x.f.v v10, v8
254 ; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma
255 ; CHECK-NEXT: vmerge.vim v8, v10, 0, v0
257 %x = call <vscale x 4 x i32> @llvm.fptosi.sat.nxv4f16.nxv4i32(<vscale x 4 x half> %f)
258 ret <vscale x 4 x i32> %x
261 define <vscale x 8 x i32> @test_signed_v8f16_v8i32(<vscale x 8 x half> %f) {
262 ; CHECK-LABEL: test_signed_v8f16_v8i32:
264 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
265 ; CHECK-NEXT: vmfne.vv v0, v8, v8
266 ; CHECK-NEXT: vfwcvt.rtz.x.f.v v12, v8
267 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
268 ; CHECK-NEXT: vmerge.vim v8, v12, 0, v0
270 %x = call <vscale x 8 x i32> @llvm.fptosi.sat.nxv8f16.nxv8i32(<vscale x 8 x half> %f)
271 ret <vscale x 8 x i32> %x
274 define <vscale x 4 x i16> @test_signed_v4f16_v4i16(<vscale x 4 x half> %f) {
275 ; CHECK-LABEL: test_signed_v4f16_v4i16:
277 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
278 ; CHECK-NEXT: vmfne.vv v0, v8, v8
279 ; CHECK-NEXT: vfcvt.rtz.x.f.v v8, v8
280 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
282 %x = call <vscale x 4 x i16> @llvm.fptosi.sat.nxv4f16.nxv4i16(<vscale x 4 x half> %f)
283 ret <vscale x 4 x i16> %x
286 define <vscale x 8 x i16> @test_signed_v8f16_v8i16(<vscale x 8 x half> %f) {
287 ; CHECK-LABEL: test_signed_v8f16_v8i16:
289 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
290 ; CHECK-NEXT: vmfne.vv v0, v8, v8
291 ; CHECK-NEXT: vfcvt.rtz.x.f.v v8, v8
292 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
294 %x = call <vscale x 8 x i16> @llvm.fptosi.sat.nxv8f16.nxv8i16(<vscale x 8 x half> %f)
295 ret <vscale x 8 x i16> %x
298 define <vscale x 2 x i64> @test_signed_v2f16_v2i64(<vscale x 2 x half> %f) {
299 ; CHECK-LABEL: test_signed_v2f16_v2i64:
301 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
302 ; CHECK-NEXT: vmfne.vv v0, v8, v8
303 ; CHECK-NEXT: vfwcvt.f.f.v v9, v8
304 ; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma
305 ; CHECK-NEXT: vfwcvt.rtz.x.f.v v10, v9
306 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma
307 ; CHECK-NEXT: vmerge.vim v8, v10, 0, v0
309 %x = call <vscale x 2 x i64> @llvm.fptosi.sat.nxv2f16.nxv2i64(<vscale x 2 x half> %f)
310 ret <vscale x 2 x i64> %x
313 define <vscale x 4 x i64> @test_signed_v4f16_v4i64(<vscale x 4 x half> %f) {
314 ; CHECK-LABEL: test_signed_v4f16_v4i64:
316 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
317 ; CHECK-NEXT: vmfne.vv v0, v8, v8
318 ; CHECK-NEXT: vfwcvt.f.f.v v10, v8
319 ; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma
320 ; CHECK-NEXT: vfwcvt.rtz.x.f.v v12, v10
321 ; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma
322 ; CHECK-NEXT: vmerge.vim v8, v12, 0, v0
324 %x = call <vscale x 4 x i64> @llvm.fptosi.sat.nxv4f16.nxv4i64(<vscale x 4 x half> %f)
325 ret <vscale x 4 x i64> %x