From 819899c74594052da45f20ce287eb10c3d51f03e Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sun, 11 Sep 2022 15:42:28 -0400 Subject: [PATCH] Implement f64 Where with u16 blocks --- src/builtins/slash.c | 51 +++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/src/builtins/slash.c b/src/builtins/slash.c index 09b1d246..c8c658c1 100644 --- a/src/builtins/slash.c +++ b/src/builtins/slash.c @@ -161,6 +161,23 @@ static void bsp_u16(u64* src, u16* dst, usz len, usz sum) { TFREE(buf); } +static void where_block_u16(u64* src, u16* dst, usz len, usz sum) { + assert(len <= bsp_max); + #if SINGELI && defined(__BMI2__) + if (sum >= len/8) bmipopc_1slash16(src, (i16*)dst, len); + #else + if (sum >= len/4+len/8) WHERE_DENSE(src, dst, len, 0); + #endif + else if (sum >= len/128) { + u32* buf = (u32*)dst; assert(sum*2 <= len); + for (usz j=0; jxia-i) { b=xia-i; bs=s-(rp-rp0); } else { bs=bit_sum(xp,b); } + where_block_u16(xp, buf, b, bs); + for (usz j=0; j=USZ_MAX) thrOOM(); if (s==0) { decG(x); return emptyIVec(); } usz xia = IA(x); - if (RARE(xia>=I32_MAX)) { - usz xia = IA(x); - SGetU(x) - f64* rp; B r = m_f64arrv(&rp, s); usz ri = 0; - for (usz i = 0; i < xia; i++) { - usz c = o2s(GetU(x, i)); - for (usz j = 0; j < c; j++) rp[ri++] = i; - } - decG(x); - return r; - } B r; u8 xe = TI(x,elType); if (xe==el_bit) { r = where(x, xia, s); + } else if (RARE(xia>=I32_MAX)) { + SGetU(x) + f64* rp; r = m_f64arrv(&rp, s); usz ri = 0; + for (usz i = 0; i < xia; i++) { + usz c = o2s(GetU(x, i)); + for (usz j = 0; j < c; j++) rp[ri++] = i; + } } else { i32* rp; r = m_i32arrv(&rp, s); if (xe==el_i8) {