From 6f03371e3b68f378423d4a2c52785d7373cb9b99 Mon Sep 17 00:00:00 2001 From: dzaima Date: Fri, 2 May 2025 03:58:47 +0300 Subject: [PATCH] =?UTF-8?q?get=20rid=20of=20most=20custom=20sel{=E2=80=A6}?= =?UTF-8?q?=20defs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/singeli/src/avx2.singeli | 4 ---- src/singeli/src/base.singeli | 6 ++---- src/singeli/src/neon.singeli | 2 +- src/singeli/src/sse.singeli | 3 --- 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/singeli/src/avx2.singeli b/src/singeli/src/avx2.singeli index 6f83a0cf..f708a6dd 100644 --- a/src/singeli/src/avx2.singeli +++ b/src/singeli/src/avx2.singeli @@ -2,10 +2,6 @@ def packQQ{a:T,b:T==[4]i64} = vec_shuffle{[4]i32, a, 0,2,1,1} | vec_shuffle{[4]i32, b, 1,1,0,2} def packQQ{{a, b}} = packQQ{a, b} -# structural operations -def sel{L, x:T, i:I if w256{T} and lvec{L,8,32} and w256{I,32}} = vec_shuffle{L, x, i} -def sel{L, x:T, i:I if w256{T} and lvec{L,16,8} and w256{I, 8}} = vec_shuffle{L, x, i} - # masked store; F variants may not be a single instruction def store_masked_top{p:*E, m:M=[k]_, v:V=[k]E if w256{V, 32} and w256i{M}} = emit{void, '_mm256_maskstore_epi32', *i32~~p, m, [8]i32~~v} def store_masked_top{p:*E, m:M=[k]_, v:V=[k]E if w256{V, 64} and w256i{M}} = emit{void, '_mm256_maskstore_pd', *f64~~p, m, [4]f64~~v} diff --git a/src/singeli/src/base.singeli b/src/singeli/src/base.singeli index a47b14de..72b1fc0a 100644 --- a/src/singeli/src/base.singeli +++ b/src/singeli/src/base.singeli @@ -167,9 +167,7 @@ def has_sel = hasarch{'AVX2'} or hasarch{'AARCH64'} def fast_BMI2{} = hasarch{'BMI2'} and not SLOW_PDEP def assert_hom{{...vs}} = each{assert_hom, vs} def assert_hom{x:[_]E if quality{E}=='u'} = x - -# test if vector has a specific width & element type -def lvec = match { {[n]T, n, (width{T})} => 1; {T, n, w} => 0 } +def sel{L=[_]_, v:[_]_, i:[_]_} = vec_shuffle{L, v, i} # base cases def { @@ -178,7 +176,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,reverse_units,broadcast_sel,absdiff_sum,mul_sum,mul_sum_sat, + 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, addp,addpw,addpwa, } diff --git a/src/singeli/src/neon.singeli b/src/singeli/src/neon.singeli index a86992af..3fb8ca28 100644 --- a/src/singeli/src/neon.singeli +++ b/src/singeli/src/neon.singeli @@ -92,7 +92,7 @@ def unzip{x:T, y:T, 1 if nvec{T}} = emit{T, ntyp{'vuzp2', T}, T~~x, T~~y} def trn{x:T, y:T, 0 if nvec{T}} = emit{T, ntyp{'vtrn1', T}, x, y} def trn{x:T, y:T, 1 if nvec{T}} = emit{T, ntyp{'vtrn2', T}, x, y} -def sel{L, x:T, i:I if lvec{L,16,8} and w128{T} and nvec{I, 8}} = vec_select{eltype{L}, x, i} +def lvec = match { {[n]T, n, (width{T})} => 1; {T, n, w} => 0 } # test if vector has a specific width & element type def sel{{...xs}, i:I if length{xs}>=1 and length{xs}<=4 and all_same{each{type,xs}} and lvec{one_type{xs},16,8} and nvec{I, 8}} = vec_select{xs, i} diff --git a/src/singeli/src/sse.singeli b/src/singeli/src/sse.singeli index 1234609f..f18ec87b 100644 --- a/src/singeli/src/sse.singeli +++ b/src/singeli/src/sse.singeli @@ -69,9 +69,6 @@ def narrow{T==i32, x:([2]f64)} = emit{[4]i32, '_mm_cvtpd_epi32', x} -# SSSE3 -def sel{L=[_]E, x:T, i:I if hasarch{'SSSE3'} and lvec{L,16,8} and w128{T} and w128i{I, 8}} = vec_select{E, x, i} - # SSE4.1 # conversion def narrow{(i8 ), x:X if hasarch{'SSE4.1'} and w128i{X,32}} = sel{[16]u8, [16]i8~~x, make{[16]i8, 0,4,8,12, 0,0,0,0, 0,0,0,0, 0,0,0,0}}