diff --git a/src/singeli/src/avx.singeli b/src/singeli/src/avx.singeli index e501884e..a1e368c2 100644 --- a/src/singeli/src/avx.singeli +++ b/src/singeli/src/avx.singeli @@ -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} diff --git a/src/singeli/src/base.singeli b/src/singeli/src/base.singeli index 320cc1af..7568ea26 100644 --- a/src/singeli/src/base.singeli +++ b/src/singeli/src/base.singeli @@ -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