From fe8892ce6ce68e5d8a24b22cd3e9f4c1f9f61efe Mon Sep 17 00:00:00 2001 From: dzaima Date: Wed, 7 Jun 2023 21:24:10 +0300 Subject: [PATCH] rearrange shrm/shlm args, slightly better NEON homMask{[16]u8} --- src/singeli/src/neon.singeli | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/singeli/src/neon.singeli b/src/singeli/src/neon.singeli index 440a45e1..e953f736 100644 --- a/src/singeli/src/neon.singeli +++ b/src/singeli/src/neon.singeli @@ -47,10 +47,11 @@ def max{a:T,b:T & nvec{T}} = emit{T, ntyp{'vmax', T}, a, b} def __shl{a:T,b:S & nveci{T} & nveci{S,elwidth{T}}} = emit{T, ntyp{'vshl', T}, a, ty_s{b}} def addp{a:T,b:T & nvec{T}} = emit{T, ntyp{'vpadd', T}, a, b} -def __shl{a:T, s & nveci{T} & knum{s} & s>0 & s0 & s8} = { def H=v_half{ty_half{T}}; emit{H, ntyp0{'vshrn_n', T}, a, s} } # a>>s, narrowed -def shrm{a:T, d:T, s & w128u{T}} = emit{T, ntyp{'vsri', '_n', T}, a, d, s} # (a>>s) | (d & newZeroesIn(a>>s)) +def __shl{a:T, s & nveci{T} & knum{s} & s>0 & s0 & s8} = { def H=v_half{ty_half{T}}; emit{H, ntyp0{'vshrn_n', T}, a, s} } # a>>s, narrowed +def shrm{a:T, s, d:T & nvecu{T}} = emit{T, ntyp{'vsri', '_n', T}, d, a, s} # (a>>s) | (d & (mask of new zeroes)) +def shlm{a:T, s, d:T & nvecu{T}} = emit{T, ntyp{'vsli', '_n', T}, d, a, s} # (a<=vcount{T}} = { truncBits{vcount{T}, fold_add{x & make{T, 1<1 & elwidth{type{tupsel{0,as}}}>=32} = homMask{...each{{i}=>narrowPair{tupsel{i*2,as},tupsel{i*2+1,as}}, iota{tuplen{as}/2}}} def homMask{a:T,b:T & vcount{T}*2<=elwidth{T}} = { def n = vcount{T} - truncBits{n*2, fold_add{shrm{b,a,elwidth{T}-n} & make{T, (1<