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 --check-prefixes=CHECK,CHECK32
4 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+zvfh,+v -target-abi=lp64d \
5 ; RUN: -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,CHECK64
9 declare <vscale x 2 x i32> @llvm.fptoui.sat.nxv2f32.nxv2i32(<vscale x 2 x float>)
10 declare <vscale x 4 x i32> @llvm.fptoui.sat.nxv4f32.nxv4i32(<vscale x 4 x float>)
11 declare <vscale x 8 x i32> @llvm.fptoui.sat.nxv8f32.nxv8i32(<vscale x 8 x float>)
12 declare <vscale x 4 x i16> @llvm.fptoui.sat.nxv4f32.nxv4i16(<vscale x 4 x float>)
13 declare <vscale x 8 x i16> @llvm.fptoui.sat.nxv8f32.nxv8i16(<vscale x 8 x float>)
14 declare <vscale x 2 x i64> @llvm.fptoui.sat.nxv2f32.nxv2i64(<vscale x 2 x float>)
15 declare <vscale x 4 x i64> @llvm.fptoui.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.xu.f.v v8, v8
23 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
25 %x = call <vscale x 2 x i32> @llvm.fptoui.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.xu.f.v v8, v8
35 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
37 %x = call <vscale x 4 x i32> @llvm.fptoui.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.xu.f.v v8, v8
47 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
49 %x = call <vscale x 8 x i32> @llvm.fptoui.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.xu.f.w v10, v8
60 ; CHECK-NEXT: vmerge.vim v8, v10, 0, v0
62 %x = call <vscale x 4 x i16> @llvm.fptoui.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.xu.f.w v12, v8
73 ; CHECK-NEXT: vmerge.vim v8, v12, 0, v0
75 %x = call <vscale x 8 x i16> @llvm.fptoui.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.xu.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.fptoui.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.xu.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.fptoui.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.fptoui.sat.nxv2f64.nxv2i32(<vscale x 2 x double>)
108 declare <vscale x 4 x i32> @llvm.fptoui.sat.nxv4f64.nxv4i32(<vscale x 4 x double>)
109 declare <vscale x 8 x i32> @llvm.fptoui.sat.nxv8f64.nxv8i32(<vscale x 8 x double>)
110 declare <vscale x 4 x i16> @llvm.fptoui.sat.nxv4f64.nxv4i16(<vscale x 4 x double>)
111 declare <vscale x 8 x i16> @llvm.fptoui.sat.nxv8f64.nxv8i16(<vscale x 8 x double>)
112 declare <vscale x 2 x i64> @llvm.fptoui.sat.nxv2f64.nxv2i64(<vscale x 2 x double>)
113 declare <vscale x 4 x i64> @llvm.fptoui.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.xu.f.w v10, v8
122 ; CHECK-NEXT: vmerge.vim v8, v10, 0, v0
124 %x = call <vscale x 2 x i32> @llvm.fptoui.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.xu.f.w v12, v8
135 ; CHECK-NEXT: vmerge.vim v8, v12, 0, v0
137 %x = call <vscale x 4 x i32> @llvm.fptoui.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.xu.f.w v16, v8
148 ; CHECK-NEXT: vmerge.vim v8, v16, 0, v0
150 %x = call <vscale x 8 x i32> @llvm.fptoui.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 ; CHECK32-LABEL: test_signed_v4f64_v4i16:
157 ; CHECK32-NEXT: lui a0, %hi(.LCPI10_0)
158 ; CHECK32-NEXT: fld fa5, %lo(.LCPI10_0)(a0)
159 ; CHECK32-NEXT: fcvt.d.w fa4, zero
160 ; CHECK32-NEXT: vsetvli a0, zero, e64, m4, ta, ma
161 ; CHECK32-NEXT: vfmax.vf v8, v8, fa4
162 ; CHECK32-NEXT: vfmin.vf v8, v8, fa5
163 ; CHECK32-NEXT: vsetvli zero, zero, e32, m2, ta, ma
164 ; CHECK32-NEXT: vfncvt.rtz.xu.f.w v12, v8
165 ; CHECK32-NEXT: vsetvli zero, zero, e16, m1, ta, ma
166 ; CHECK32-NEXT: vnsrl.wi v8, v12, 0
169 ; CHECK64-LABEL: test_signed_v4f64_v4i16:
171 ; CHECK64-NEXT: lui a0, %hi(.LCPI10_0)
172 ; CHECK64-NEXT: fld fa5, %lo(.LCPI10_0)(a0)
173 ; CHECK64-NEXT: fmv.d.x fa4, zero
174 ; CHECK64-NEXT: vsetvli a0, zero, e64, m4, ta, ma
175 ; CHECK64-NEXT: vfmax.vf v8, v8, fa4
176 ; CHECK64-NEXT: vfmin.vf v8, v8, fa5
177 ; CHECK64-NEXT: vsetvli zero, zero, e32, m2, ta, ma
178 ; CHECK64-NEXT: vfncvt.rtz.xu.f.w v12, v8
179 ; CHECK64-NEXT: vsetvli zero, zero, e16, m1, ta, ma
180 ; CHECK64-NEXT: vnsrl.wi v8, v12, 0
182 %x = call <vscale x 4 x i16> @llvm.fptoui.sat.nxv4f64.nxv4i16(<vscale x 4 x double> %f)
183 ret <vscale x 4 x i16> %x
186 define <vscale x 8 x i16> @test_signed_v8f64_v8i16(<vscale x 8 x double> %f) {
187 ; CHECK32-LABEL: test_signed_v8f64_v8i16:
189 ; CHECK32-NEXT: lui a0, %hi(.LCPI11_0)
190 ; CHECK32-NEXT: fld fa5, %lo(.LCPI11_0)(a0)
191 ; CHECK32-NEXT: fcvt.d.w fa4, zero
192 ; CHECK32-NEXT: vsetvli a0, zero, e64, m8, ta, ma
193 ; CHECK32-NEXT: vfmax.vf v8, v8, fa4
194 ; CHECK32-NEXT: vfmin.vf v8, v8, fa5
195 ; CHECK32-NEXT: vsetvli zero, zero, e32, m4, ta, ma
196 ; CHECK32-NEXT: vfncvt.rtz.xu.f.w v16, v8
197 ; CHECK32-NEXT: vsetvli zero, zero, e16, m2, ta, ma
198 ; CHECK32-NEXT: vnsrl.wi v8, v16, 0
201 ; CHECK64-LABEL: test_signed_v8f64_v8i16:
203 ; CHECK64-NEXT: lui a0, %hi(.LCPI11_0)
204 ; CHECK64-NEXT: fld fa5, %lo(.LCPI11_0)(a0)
205 ; CHECK64-NEXT: fmv.d.x fa4, zero
206 ; CHECK64-NEXT: vsetvli a0, zero, e64, m8, ta, ma
207 ; CHECK64-NEXT: vfmax.vf v8, v8, fa4
208 ; CHECK64-NEXT: vfmin.vf v8, v8, fa5
209 ; CHECK64-NEXT: vsetvli zero, zero, e32, m4, ta, ma
210 ; CHECK64-NEXT: vfncvt.rtz.xu.f.w v16, v8
211 ; CHECK64-NEXT: vsetvli zero, zero, e16, m2, ta, ma
212 ; CHECK64-NEXT: vnsrl.wi v8, v16, 0
214 %x = call <vscale x 8 x i16> @llvm.fptoui.sat.nxv8f64.nxv8i16(<vscale x 8 x double> %f)
215 ret <vscale x 8 x i16> %x
218 define <vscale x 2 x i64> @test_signed_v2f64_v2i64(<vscale x 2 x double> %f) {
219 ; CHECK-LABEL: test_signed_v2f64_v2i64:
221 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
222 ; CHECK-NEXT: vmfne.vv v0, v8, v8
223 ; CHECK-NEXT: vfcvt.rtz.xu.f.v v8, v8
224 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
226 %x = call <vscale x 2 x i64> @llvm.fptoui.sat.nxv2f64.nxv2i64(<vscale x 2 x double> %f)
227 ret <vscale x 2 x i64> %x
230 define <vscale x 4 x i64> @test_signed_v4f64_v4i64(<vscale x 4 x double> %f) {
231 ; CHECK-LABEL: test_signed_v4f64_v4i64:
233 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
234 ; CHECK-NEXT: vmfne.vv v0, v8, v8
235 ; CHECK-NEXT: vfcvt.rtz.xu.f.v v8, v8
236 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
238 %x = call <vscale x 4 x i64> @llvm.fptoui.sat.nxv4f64.nxv4i64(<vscale x 4 x double> %f)
239 ret <vscale x 4 x i64> %x
245 declare <vscale x 2 x i32> @llvm.fptoui.sat.nxv2f16.nxv2i32(<vscale x 2 x half>)
246 declare <vscale x 4 x i32> @llvm.fptoui.sat.nxv4f16.nxv4i32(<vscale x 4 x half>)
247 declare <vscale x 8 x i32> @llvm.fptoui.sat.nxv8f16.nxv8i32(<vscale x 8 x half>)
248 declare <vscale x 4 x i16> @llvm.fptoui.sat.nxv4f16.nxv4i16(<vscale x 4 x half>)
249 declare <vscale x 8 x i16> @llvm.fptoui.sat.nxv8f16.nxv8i16(<vscale x 8 x half>)
250 declare <vscale x 2 x i64> @llvm.fptoui.sat.nxv2f16.nxv2i64(<vscale x 2 x half>)
251 declare <vscale x 4 x i64> @llvm.fptoui.sat.nxv4f16.nxv4i64(<vscale x 4 x half>)
253 define <vscale x 2 x i32> @test_signed_v2f16_v2i32(<vscale x 2 x half> %f) {
254 ; CHECK-LABEL: test_signed_v2f16_v2i32:
256 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
257 ; CHECK-NEXT: vmfne.vv v0, v8, v8
258 ; CHECK-NEXT: vfwcvt.rtz.xu.f.v v9, v8
259 ; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma
260 ; CHECK-NEXT: vmerge.vim v8, v9, 0, v0
262 %x = call <vscale x 2 x i32> @llvm.fptoui.sat.nxv2f16.nxv2i32(<vscale x 2 x half> %f)
263 ret <vscale x 2 x i32> %x
266 define <vscale x 4 x i32> @test_signed_v4f16_v4i32(<vscale x 4 x half> %f) {
267 ; CHECK-LABEL: test_signed_v4f16_v4i32:
269 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
270 ; CHECK-NEXT: vmfne.vv v0, v8, v8
271 ; CHECK-NEXT: vfwcvt.rtz.xu.f.v v10, v8
272 ; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma
273 ; CHECK-NEXT: vmerge.vim v8, v10, 0, v0
275 %x = call <vscale x 4 x i32> @llvm.fptoui.sat.nxv4f16.nxv4i32(<vscale x 4 x half> %f)
276 ret <vscale x 4 x i32> %x
279 define <vscale x 8 x i32> @test_signed_v8f16_v8i32(<vscale x 8 x half> %f) {
280 ; CHECK-LABEL: test_signed_v8f16_v8i32:
282 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
283 ; CHECK-NEXT: vmfne.vv v0, v8, v8
284 ; CHECK-NEXT: vfwcvt.rtz.xu.f.v v12, v8
285 ; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma
286 ; CHECK-NEXT: vmerge.vim v8, v12, 0, v0
288 %x = call <vscale x 8 x i32> @llvm.fptoui.sat.nxv8f16.nxv8i32(<vscale x 8 x half> %f)
289 ret <vscale x 8 x i32> %x
292 define <vscale x 4 x i16> @test_signed_v4f16_v4i16(<vscale x 4 x half> %f) {
293 ; CHECK-LABEL: test_signed_v4f16_v4i16:
295 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
296 ; CHECK-NEXT: vmfne.vv v0, v8, v8
297 ; CHECK-NEXT: vfcvt.rtz.xu.f.v v8, v8
298 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
300 %x = call <vscale x 4 x i16> @llvm.fptoui.sat.nxv4f16.nxv4i16(<vscale x 4 x half> %f)
301 ret <vscale x 4 x i16> %x
304 define <vscale x 8 x i16> @test_signed_v8f16_v8i16(<vscale x 8 x half> %f) {
305 ; CHECK-LABEL: test_signed_v8f16_v8i16:
307 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
308 ; CHECK-NEXT: vmfne.vv v0, v8, v8
309 ; CHECK-NEXT: vfcvt.rtz.xu.f.v v8, v8
310 ; CHECK-NEXT: vmerge.vim v8, v8, 0, v0
312 %x = call <vscale x 8 x i16> @llvm.fptoui.sat.nxv8f16.nxv8i16(<vscale x 8 x half> %f)
313 ret <vscale x 8 x i16> %x
316 define <vscale x 2 x i64> @test_signed_v2f16_v2i64(<vscale x 2 x half> %f) {
317 ; CHECK-LABEL: test_signed_v2f16_v2i64:
319 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
320 ; CHECK-NEXT: vmfne.vv v0, v8, v8
321 ; CHECK-NEXT: vfwcvt.f.f.v v9, v8
322 ; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma
323 ; CHECK-NEXT: vfwcvt.rtz.xu.f.v v10, v9
324 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma
325 ; CHECK-NEXT: vmerge.vim v8, v10, 0, v0
327 %x = call <vscale x 2 x i64> @llvm.fptoui.sat.nxv2f16.nxv2i64(<vscale x 2 x half> %f)
328 ret <vscale x 2 x i64> %x
331 define <vscale x 4 x i64> @test_signed_v4f16_v4i64(<vscale x 4 x half> %f) {
332 ; CHECK-LABEL: test_signed_v4f16_v4i64:
334 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
335 ; CHECK-NEXT: vmfne.vv v0, v8, v8
336 ; CHECK-NEXT: vfwcvt.f.f.v v10, v8
337 ; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma
338 ; CHECK-NEXT: vfwcvt.rtz.xu.f.v v12, v10
339 ; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma
340 ; CHECK-NEXT: vmerge.vim v8, v12, 0, v0
342 %x = call <vscale x 4 x i64> @llvm.fptoui.sat.nxv4f16.nxv4i64(<vscale x 4 x half> %f)
343 ret <vscale x 4 x i64> %x