diff --git a/src/singeli/src/avx.singeli b/src/singeli/src/avx.singeli index 694dfabf..f7841e89 100644 --- a/src/singeli/src/avx.singeli +++ b/src/singeli/src/avx.singeli @@ -15,12 +15,6 @@ def widen{T=[k]_, x:X=[l]_ if w256{X} and l>k} = widen{T, half{x,0}} def blend_top{f:T, t:T, m:M if w256i{T,32} and w256i{M,32}} = T ~~ blend_top{v2f{f}, v2f{t}, v2f{m}} def blend_top{f:T, t:T, m:M if w256i{T,64} and w256i{M,64}} = T ~~ blend_top{v2d{f}, v2d{t}, v2d{m}} -# shuffles -def shuf_ind{a:T, b:T=[8]E, {...is} if width{E}==32 and length{is}==8 and ({l,h} => same{l,h-4} and x86_shufps_range{l, 8}){slice{is,0,4}, slice{is,4,8}}} = { - vec_shuffle{[4]f32, tup{a, b}, slice{is,0,4} & 3} -} -def shuf_ind{a:T, b:T=[4]E, {...is} if width{E}==64 and length{is}==4} = T~~shuf_ind{re_el{u32,a}, re_el{u32,b}, merge{...each{{i} => tup{i*2, i*2+1}, is}}} - # mask stuff def and_bit_none{x:T, y:T if w256i{T}} = emit{u1, '_mm256_testz_si256', x, y} diff --git a/src/singeli/src/avx2.singeli b/src/singeli/src/avx2.singeli index d7d926fe..11c5740d 100644 --- a/src/singeli/src/avx2.singeli +++ b/src/singeli/src/avx2.singeli @@ -67,8 +67,8 @@ def unzip128{a:[k]E, b:[k]E, 1 if hasarch{'X86_64'} and isunsigned{E}} = { def ew = width{E} packs128{re_el{ED,a} >> ew, re_el{ED,b} >> ew} } -def unzip128{a:T, b:T==[8](u32), k} = shuf_ind{a, b, tup{0,2,8,10, 4,6,12,14}+k} -def unzip128{a:T, b:T==[4](u64), k} = shuf_ind{a, b, tup{0,4,2,6}+k} +def unzip128{a:V, b:V if vece{V,32}, k if int_idx{k,2}} = vec_shuffle{[4]f32, tup{a,b}, k+tup{0,2,0,2}} +def unzip128{a:V, b:V if vece{V,64}, k if int_idx{k,2}} = vec_shuffle{[2]f64, tup{a,b}, k+tup{0,0}} def unzip{a:T, b:T, k if w128u{T} and hasarch{'SSE2'}} = unzip128{a, b, k} def unzip{a:T, b:T, k if w256u{T} and hasarch{'AVX2'}} = vec_shuffle{[4]u64, unzip128{a, b, k}, 0,2,1,3} diff --git a/src/singeli/src/base.singeli b/src/singeli/src/base.singeli index 3a649f81..1c311d0d 100644 --- a/src/singeli/src/base.singeli +++ b/src/singeli/src/base.singeli @@ -178,7 +178,7 @@ 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,bzhi,rbit,sel,shuf_ind,reverse_units,broadcast_sel,absdiff_sum,mul_sum,mul_sum_sat, + pair,pdep,pext,bzhi,rbit,sel,reverse_units,broadcast_sel,absdiff_sum,mul_sum,mul_sum_sat, unord,unzip,vfold,vec_select,vec_shuffle,widen,widen_upper,multishift, addp,addpw,addpwa, } @@ -357,11 +357,6 @@ def in_range_len{x:TU=[_]T, start, count if isunsigned{T}} = { # ∊ [start;star (TS~~(x-TU**(start-h))) < TS**(count-h) } -# check if all tuple elements are in a given range -def in_range{t, min, max} = all{(t>=min) & (t tup{1,3,5,7} - {4} => tup{1,3,9,11,5,7,13,15} # all odd indices, in the order that vshufps can handle - }} + def hi = if (hasarch{'X86_64'}) T32~~vec_shuffle{[4]f32, tup{x, y}, 1,3,1,3} # gathers all odd-positioned 32-bit elements from both vectors in whatever order that vshufps can handle + else pack{x, y, 1} anyne{hi, T32**cast_i{u32, cbqn_c32Tag{}<<16}, mask_none} } diff --git a/src/singeli/src/sse.singeli b/src/singeli/src/sse.singeli index 36cd7471..e22955f0 100644 --- a/src/singeli/src/sse.singeli +++ b/src/singeli/src/sse.singeli @@ -41,9 +41,6 @@ def all_top{x:T=[k]_ if w128i{T}} = top_to_int{x} == (1<elwidth{X}} = {