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, e64, m4, ta, ma
167 ; CHECK-NEXT: vmfne.vv v0, v8, v8
168 ; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, ma
169 ; CHECK-NEXT: vnsrl.wi v8, v16, 0
170 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
172 %x = call <vscale x 4 x i16> @llvm.fptosi.sat.nxv4f64.nxv4i16(<vscale x 4 x double> %f)
173 ret <vscale x 4 x i16> %x
176 define <vscale x 8 x i16> @test_signed_v8f64_v8i16(<vscale x 8 x double> %f) {
177 ; CHECK-LABEL: test_signed_v8f64_v8i16:
179 ; CHECK-NEXT: lui a0, %hi(.LCPI11_0)
180 ; CHECK-NEXT: fld fa5, %lo(.LCPI11_0)(a0)
181 ; CHECK-NEXT: lui a0, %hi(.LCPI11_1)
182 ; CHECK-NEXT: fld fa4, %lo(.LCPI11_1)(a0)
183 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
184 ; CHECK-NEXT: vfmax.vf v16, v8, fa5
185 ; CHECK-NEXT: vfmin.vf v16, v16, fa4
186 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
187 ; CHECK-NEXT: vfncvt.rtz.x.f.w v24, v16
188 ; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma
189 ; CHECK-NEXT: vmfne.vv v0, v8, v8
190 ; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, ma
191 ; CHECK-NEXT: vnsrl.wi v8, v24, 0
192 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
194 %x = call <vscale x 8 x i16> @llvm.fptosi.sat.nxv8f64.nxv8i16(<vscale x 8 x double> %f)
195 ret <vscale x 8 x i16> %x
198 define <vscale x 2 x i64> @test_signed_v2f64_v2i64(<vscale x 2 x double> %f) {
199 ; CHECK-LABEL: test_signed_v2f64_v2i64:
201 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
202 ; CHECK-NEXT: vmfne.vv v0, v8, v8
203 ; CHECK-NEXT: vfcvt.rtz.x.f.v v8, v8
204 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
206 %x = call <vscale x 2 x i64> @llvm.fptosi.sat.nxv2f64.nxv2i64(<vscale x 2 x double> %f)
207 ret <vscale x 2 x i64> %x
210 define <vscale x 4 x i64> @test_signed_v4f64_v4i64(<vscale x 4 x double> %f) {
211 ; CHECK-LABEL: test_signed_v4f64_v4i64:
213 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
214 ; CHECK-NEXT: vmfne.vv v0, v8, v8
215 ; CHECK-NEXT: vfcvt.rtz.x.f.v v8, v8
216 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
218 %x = call <vscale x 4 x i64> @llvm.fptosi.sat.nxv4f64.nxv4i64(<vscale x 4 x double> %f)
219 ret <vscale x 4 x i64> %x
225 declare <vscale x 2 x i32> @llvm.fptosi.sat.nxv2f16.nxv2i32(<vscale x 2 x half>)
226 declare <vscale x 4 x i32> @llvm.fptosi.sat.nxv4f16.nxv4i32(<vscale x 4 x half>)
227 declare <vscale x 8 x i32> @llvm.fptosi.sat.nxv8f16.nxv8i32(<vscale x 8 x half>)
228 declare <vscale x 4 x i16> @llvm.fptosi.sat.nxv4f16.nxv4i16(<vscale x 4 x half>)
229 declare <vscale x 8 x i16> @llvm.fptosi.sat.nxv8f16.nxv8i16(<vscale x 8 x half>)
230 declare <vscale x 2 x i64> @llvm.fptosi.sat.nxv2f16.nxv2i64(<vscale x 2 x half>)
231 declare <vscale x 4 x i64> @llvm.fptosi.sat.nxv4f16.nxv4i64(<vscale x 4 x half>)
233 define <vscale x 2 x i32> @test_signed_v2f16_v2i32(<vscale x 2 x half> %f) {
234 ; CHECK-LABEL: test_signed_v2f16_v2i32:
236 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
237 ; CHECK-NEXT: vmfne.vv v0, v8, v8
238 ; CHECK-NEXT: vfwcvt.rtz.x.f.v v9, v8
239 ; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma
240 ; CHECK-NEXT: vmerge.vim v8, v9, 0, v0
242 %x = call <vscale x 2 x i32> @llvm.fptosi.sat.nxv2f16.nxv2i32(<vscale x 2 x half> %f)
243 ret <vscale x 2 x i32> %x
246 define <vscale x 4 x i32> @test_signed_v4f16_v4i32(<vscale x 4 x half> %f) {
247 ; CHECK-LABEL: test_signed_v4f16_v4i32:
249 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
250 ; CHECK-NEXT: vmfne.vv v0, v8, v8
251 ; CHECK-NEXT: vfwcvt.rtz.x.f.v v10, v8
252 ; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma
253 ; CHECK-NEXT: vmerge.vim v8, v10, 0, v0
255 %x = call <vscale x 4 x i32> @llvm.fptosi.sat.nxv4f16.nxv4i32(<vscale x 4 x half> %f)
256 ret <vscale x 4 x i32> %x
259 define <vscale x 8 x i32> @test_signed_v8f16_v8i32(<vscale x 8 x half> %f) {
260 ; CHECK-LABEL: test_signed_v8f16_v8i32:
262 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
263 ; CHECK-NEXT: vmfne.vv v0, v8, v8
264 ; CHECK-NEXT: vfwcvt.rtz.x.f.v v12, v8
265 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
266 ; CHECK-NEXT: vmerge.vim v8, v12, 0, v0
268 %x = call <vscale x 8 x i32> @llvm.fptosi.sat.nxv8f16.nxv8i32(<vscale x 8 x half> %f)
269 ret <vscale x 8 x i32> %x
272 define <vscale x 4 x i16> @test_signed_v4f16_v4i16(<vscale x 4 x half> %f) {
273 ; CHECK-LABEL: test_signed_v4f16_v4i16:
275 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
276 ; CHECK-NEXT: vmfne.vv v0, v8, v8
277 ; CHECK-NEXT: vfcvt.rtz.x.f.v v8, v8
278 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
280 %x = call <vscale x 4 x i16> @llvm.fptosi.sat.nxv4f16.nxv4i16(<vscale x 4 x half> %f)
281 ret <vscale x 4 x i16> %x
284 define <vscale x 8 x i16> @test_signed_v8f16_v8i16(<vscale x 8 x half> %f) {
285 ; CHECK-LABEL: test_signed_v8f16_v8i16:
287 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
288 ; CHECK-NEXT: vmfne.vv v0, v8, v8
289 ; CHECK-NEXT: vfcvt.rtz.x.f.v v8, v8
290 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
292 %x = call <vscale x 8 x i16> @llvm.fptosi.sat.nxv8f16.nxv8i16(<vscale x 8 x half> %f)
293 ret <vscale x 8 x i16> %x
296 define <vscale x 2 x i64> @test_signed_v2f16_v2i64(<vscale x 2 x half> %f) {
297 ; CHECK-LABEL: test_signed_v2f16_v2i64:
299 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
300 ; CHECK-NEXT: vmfne.vv v0, v8, v8
301 ; CHECK-NEXT: vfwcvt.f.f.v v9, v8
302 ; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma
303 ; CHECK-NEXT: vfwcvt.rtz.x.f.v v10, v9
304 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma
305 ; CHECK-NEXT: vmerge.vim v8, v10, 0, v0
307 %x = call <vscale x 2 x i64> @llvm.fptosi.sat.nxv2f16.nxv2i64(<vscale x 2 x half> %f)
308 ret <vscale x 2 x i64> %x
311 define <vscale x 4 x i64> @test_signed_v4f16_v4i64(<vscale x 4 x half> %f) {
312 ; CHECK-LABEL: test_signed_v4f16_v4i64:
314 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
315 ; CHECK-NEXT: vmfne.vv v0, v8, v8
316 ; CHECK-NEXT: vfwcvt.f.f.v v10, v8
317 ; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma
318 ; CHECK-NEXT: vfwcvt.rtz.x.f.v v12, v10
319 ; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma
320 ; CHECK-NEXT: vmerge.vim v8, v12, 0, v0
322 %x = call <vscale x 4 x i64> @llvm.fptosi.sat.nxv4f16.nxv4i64(<vscale x 4 x half> %f)
323 ret <vscale x 4 x i64> %x