diff --git a/src/singeli/src/replicate.singeli b/src/singeli/src/replicate.singeli index b14c29b3..2d584525 100644 --- a/src/singeli/src/replicate.singeli +++ b/src/singeli/src/replicate.singeli @@ -291,25 +291,8 @@ exportT{'si_constrep', each{rep_const, dat_types}} # Constant replicate on boolean fn rep_const_bool{}(wv:usz, x:*u64, r:*u64, rlen:usz) : u1 = { - def has_pdep = hasarch{'BMI2'} + def has_pdep = 0 # Obselete, kept here for descriptiveness if (wv > 32) return{0} - if (hasarch{'SSSE3'}) { - if (wv&1 == 0) { - p := ctz{wv | 8} # Power of two for second replicate - if (wv>>p == 1) { - rep_const_bool_ssse3_div8{wv, x, r, rlen} - } else { - tlen := rlen>>p - t := r + cdiv{rlen, 64} - cdiv{tlen, 64} - rep_const_bool{}(wv >>p, x, t, tlen) - rep_const_bool{}(usz~~1<
32) return{0} + if (wv&1 == 0) { + p := ctz{wv | 8} # Power of two for second replicate + if (wv>>p == 1) { + rep_const_bool_ssse3_div8{wv, x, r, rlen} + } else { + tlen := rlen>>p + t := r + cdiv{rlen, 64} - cdiv{tlen, 64} + rep_const_bool{}(wv >>p, x, t, tlen) + rep_const_bool{}(usz~~1<
>4) & m4}
}
@@ -455,7 +455,7 @@ def rep_const_bool_ssse3_odd{wv, x, r, rlen} = { # wv odd, wv<=15
# 3: dedicated loop
i:usz = 0; while (1) {
# 01234567 to 05316427 on each byte
- xv := get_perm_x{i}; ++i
+ xv := perm_x{load{*V~~x, i}}; ++i
# Overhang from previous 64-bit elements
def ix = 64*slice{iota{3},1} // 3 # bits that overhang within a word
def ib = ix // 8 # byte index
@@ -503,7 +503,7 @@ def rep_const_bool_ssse3_odd{wv, x, r, rlen} = { # wv odd, wv<=15
while (1) {
--q; if (q == 0) { q = wv
# Load and permute bytes
- xv = get_perm_x{i}; ++i
+ xv = perm_x{load{*V~~x, i}}; ++i
# Bytes for overhang
xo = V~~((W~~xv & xom) >> (8 - wv))
xo += xo > V**0
@@ -522,35 +522,42 @@ def rep_const_bool_ssse3_odd{wv, x, r, rlen} = { # wv odd, wv<=15
o := xo & mkV{255 * (iV%8 == 0)} # overhang
output{rv | o}
}
- } else { # wv < 16
- # 9, 11, 13, 15: shared constant computation and loop
- # Initializers, relying on vl%wv == vl-wv in various ways
- wV:= V**cast_i{u8,wv}
- ind0 := (iota{V} < wV) + V**1 # mkV{iV >= k}
+ } else { # wv < 32
+ # 9 to 31: extend k*i % 8 transform to k*i % 128 by pairwise swaps
+ # Swap data goes in a pre-computed table
+ def swdat{k} = {
+ def bits = (k*iota{128} >> merge{0, replicate{1<