AVX-512 masked_mov & compress

This commit is contained in:
dzaima 2025-05-30 04:29:29 +03:00
parent bbc47cd81e
commit 13a64e4f56
2 changed files with 29 additions and 0 deletions

View File

@ -36,3 +36,31 @@ def multishift{a:[k](u64), i:V=[(k*8)](u8) if has512{V, 'VBMI'}} = emit{V, intri
def narrow{DE, x:[k]SE if isint{DE} and quality{DE}==quality{SE} and x86_has512e{[k]SE}} = {
emit{x86_vec_low{k,DE}, intrin{[k]SE, 'cvtepi', fmtwidth{SE}, '_epi', fmtwidth{DE}}, x}
}
local def masked_op{name, pattern} = {
def ok{args, k, base} = {
def got = match (...args) {
(pattern)
{..._} => tup{}
}
match (got, k, base) {
{{V=[k]_, ..._}, k, 0 } => 1
{{V=[k]_, ..._}, k, _:V} => 1
{..._} => 0
}
}
def me{...args, m:[k](u1), base if ok{args, k, base}} = {
def {V,...rest} = pattern{...args}
def has_base = not is{base,0}
emit{V,
intrin_i{V, merge{if (has_base) 'mask_' else 'maskz_', name}},
...has_base**base,
m,
...rest
}
}
}
def masked_op1{name} = masked_op{name, {a:V if has512e{V}} => tup{V,a}}
def masked_mov{...} = masked_op1{'mov'}
def compress{...} = masked_op1{'compress'}

View File

@ -178,6 +178,7 @@ def {
load_expand_bits,make,mask_to_hom,mulw_split,mulh,narrow,narrow_trunc,narrow_pair,
pair,pdep,pext,bzhi,rbit,reverse_units,broadcast_sel,absdiff_sum,mul_sum,mul_sum_sat,
unord,unzip,vfold,vec_select,vec_shuffle,widen,widen_upper,multishift,lowelt_mask,
masked_mov,compress,
addp,addpw,addpwa,
}