From ccb1f5fa3433516f840a101d529e7d818362e988 Mon Sep 17 00:00:00 2001 From: dzaima Date: Sun, 27 Apr 2025 22:13:06 +0300 Subject: [PATCH] =?UTF-8?q?proper=20x86=20i32=E2=86=92float=20convert=20de?= =?UTF-8?q?finiton?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/singeli/src/dyarith.singeli | 3 +-- src/singeli/src/x86.singeli | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/singeli/src/dyarith.singeli b/src/singeli/src/dyarith.singeli index c2e359e1..a53632f0 100644 --- a/src/singeli/src/dyarith.singeli +++ b/src/singeli/src/dyarith.singeli @@ -53,8 +53,7 @@ def arithChk2{F==__mul, M, w:T=[_](i16), x:T if hasarch{'X86_64'}} = { } def arithChk2{F==__mul, M, w:T=[_](i32), x:T if hasarch{'X86_64'}} = { max:= re_el{f32, (ty_u{T})**0x4efffffe} - def cf32{x:X} = emit{re_el{f32,X}, tern{T==[8]i32, '_mm256_cvtepi32_ps', '_mm_cvtepi32_ps'}, x} - f32mul:= cf32{w} * cf32{x} + f32mul:= cvt{f32,w} * cvt{f32,x} tup{w*x, tup{'any_hom', M{__abs{f32mul} >= max}}} # TODO fallback to the below if the above fails # TODO don't do this, but instead shuffle one half, do math, unshuffle that half diff --git a/src/singeli/src/x86.singeli b/src/singeli/src/x86.singeli index e846ef60..7139e639 100644 --- a/src/singeli/src/x86.singeli +++ b/src/singeli/src/x86.singeli @@ -92,6 +92,10 @@ local def avx_cmp{a:V, b:V, imm} = ty_u{emit{V, intrin_t{V, 'cmp'}, a, b, imm}} def unord{a:V, b:V if w256f{V} and hasarch{'AVX'}} = avx_cmp{a,b,3} def unord{a:V, b:V if w128f{V}} = ty_u{emit{V, intrin_t{V, 'cmpunord'}, a, b}} +def cvt{RE, x:V=[k]E if isfloat{RE} and vecs{V,32} and hase{V}} = { + def RV = [k]RE + emit{RV, intrin_t{RV, 'cvtepi32'}, x} +} # int stuff