add x86 sad & madd intrinsics

This commit is contained in:
dzaima 2025-03-20 21:17:52 +02:00
parent 9876d1d622
commit 6c6f6e4013
2 changed files with 12 additions and 1 deletions

View File

@ -179,8 +179,9 @@ def {
all_hom,any_hom,blend_hom,hom_to_int,store_masked_hom,store_blended_hom,
all_top,any_top,blend_top,top_to_int,store_masked_top,store_blended_top,
load_expand_bits,make,mask_to_hom,mulw_split,mulh,narrow,narrow_trunc,narrow_pair,
pair,pdep,pext,rbit,sel,shuf_ind,reverse_units,broadcast_sel,
pair,pdep,pext,rbit,sel,shuf_ind,reverse_units,broadcast_sel,absdiff_sum,mul_sum,
unord,unzip,vfold,vec_select,vec_shuffle,widen,widen_upper,multishift,
addp,addpw,addpwa,
}
# extended by arch/*/select where applicable

View File

@ -6,3 +6,13 @@ include './avx'
include './avx2'
include './avx512'
def any_bit{x:[_]_} = ~and_bit_none{x, x}
local def has_bw{V} = hasarch{match (width{V}) { {128}=>'SSE2'; {256}=>'AVX2'; {512}=>'AVX512BW' }}
local def intrin{V, ...rest} = merge{'_mm', if (width{V}==128) '' else fmtnat{width{V}}, '_', ...rest}
def absdiff_sum{8, a:V=[k](u8), b:V if has_bw{V}} = {
emit{[k/8]u64, intrin{V, 'sad_epu8'}, a, b}
}
def mul_sum{2, a:V=[k](i16), b:V if has_bw{V}} = {
emit{[k/2]i32, intrin{V, 'madd_epi16'}, a, b}
}