proper x86 i32→float convert definiton

This commit is contained in:
dzaima 2025-04-27 22:13:06 +03:00
parent f72f554a54
commit ccb1f5fa34
2 changed files with 5 additions and 2 deletions

View File

@ -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

View File

@ -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