This converts an `i32x4` into an `f32x4` with some rounding either by using an AVX512VL/F instruction--VCVTUDQ2PS--or a long sequence of SSE4.1 compatible instructions.
23 lines
502 B
Plaintext
23 lines
502 B
Plaintext
test run
|
|
set enable_simd
|
|
target x86_64
|
|
|
|
function %fcvt_from_sint() -> b1 {
|
|
block0:
|
|
v0 = vconst.i32x4 [-1 0 1 123456789]
|
|
v1 = fcvt_from_sint.f32x4 v0
|
|
|
|
v2 = vconst.f32x4 [-0x1.0 0.0 0x1.0 0x75bcd18.0] ; 123456789 rounds to 123456792.0, an error of 3
|
|
v3 = fcmp eq v1, v2
|
|
v4 = vall_true v3
|
|
return v4
|
|
}
|
|
; run
|
|
|
|
function %fcvt_from_uint(i32x4) -> f32x4 {
|
|
block0(v0:i32x4):
|
|
v1 = fcvt_from_uint.f32x4 v0
|
|
return v1
|
|
}
|
|
; run: %fcvt_from_uint([0 0 0 0]) == [0x0.0 0x0.0 0x0.0 0x0.0]
|