shufps Singeli mapping

This commit is contained in:
dzaima 2024-07-08 22:49:01 +03:00
parent e96948cb64
commit d66be091be
3 changed files with 10 additions and 1 deletions

View File

@ -39,6 +39,10 @@ def topBlend{f:T, t:T, m:M if w256{T,32} and w256i{M,32}} = T ~~ emit{[8]f32, '_
def topBlend{f:T, t:T, m:M if w256{T,64} and w256i{M,64}} = T ~~ emit{[4]f64, '_mm256_blendv_pd', v2d{f}, v2d{t}, v2d{m}}
def homBlend{f:T, t:T, m:M if w256{T}} = topBlend{f, t, m}
# shuffles
def shufInd{a:T, b:T=[8]E, {...is} if width{E}==32 and length{is}==8 and ({l,h} => tree_fold{&, l==h-4} and x86_shufps_range{l, 8}){slice{is,0,4}, slice{is,4,8}}} = {
T~~emit{[8]f32, '_mm256_shuffle_ps', v2f{a}, v2f{b}, base{4, slice{is,0,4} & 3}}
}
# mask stuff
def andAllZero{x:T, y:T if w256i{T}} = emit{u1, '_mm256_testz_si256', x, y}

View File

@ -161,7 +161,7 @@ def {
absu,andAllZero,andnz,b_getBatch,blend,clmul,cvt,extract,fold_addw,half,
homAll,homAny,homBlend,homMask,homMaskStore,homMaskStoreF,loadBatchBit,
loadLow,make,maskStore,maskToHom,mulw,mulh,narrow,narrowPair,packHi,packLo,packQ,pair,pdep,
pext,popcRand,sel,shl,shr,shuf,shuf16Hi,shuf16Lo,shufHalves,storeLow,
pext,popcRand,sel,shl,shr,shuf,shuf16Hi,shuf16Lo,shufHalves,shufInd,storeLow,
topBlend,topMask,topMaskStore,topMaskStoreF,unord,vfold,widen,
zipHi,zipLo
}
@ -270,6 +270,9 @@ def inRangeLen{x:TU=[_]T, start, count if isunsigned{T}} = { # ∊ [start;start+
def inRangeIncl{x:T, start, end} = inRangeLen{x, start, end-start+1} # ∊ [start;end]
def inRangeExcl{x:T, start, end} = inRangeLen{x, start, end-start} # ∊ [start;end)
# check if all tuple elements are in a given range
def inrange{t, min, max} = tree_fold{&, (t>=min) & (t<max)}
def inrange{t, s, e, min, max} = inrange{slice{t,s,e}, min, max}
def load{p,i if kgen{p}} = p{i}

View File

@ -77,6 +77,8 @@ def zipHi{a:T, b:T if w128{T}} = emit{T, merge{'_mm_unpackhi',x86_postfix{eltype
def shuf{L, x:T, n if w128{T} and lvec{L,4,32} and knum{n}} = T ~~ emit{[4]i32, '_mm_shuffle_epi32', v2i{x}, n}
def shuf16Lo{x:T, n} = T~~emit{[8]i16, '_mm_shufflelo_epi16', x, n}
def shuf16Hi{x:T, n} = T~~emit{[8]i16, '_mm_shufflehi_epi16', x, n}
def x86_shufps_range{is, hi} = inrange{is,0,2, 0,4} and inrange{is,2,4, hi,hi+4}
def shufInd{a:T, b:T=[4]E, {...is} if width{E}==32 and length{is}==4 and x86_shufps_range{is, 4}} = T~~emit{[4]f32, '_mm_shuffle_ps', v2f{a}, v2f{b}, base{4, is&3}}
def homBlend{f:T, t:T, m:M if w128{T} and w128i{M,elwidth{T}}} = T ~~ ((M~~t & m) | (M~~f &~ m))
def homMaskStoreF{p:*T, m:M, v:T if w128i{M} and w128{T,elwidth{M}}} = store{p, 0, homBlend{load{p}, v, m}}