From d7b508ff3bf61b11f0b6aad7167c1cd74d9c0fd1 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Tue, 29 Oct 2024 22:38:06 -0400 Subject: [PATCH] =?UTF-8?q?Move=20select=5Fcells=5Fsingle=20(atom=E2=8A=B8?= =?UTF-8?q?=E2=8A=8F=CB=98)=20to=20select.c=20and=20use=20for=20any=20sing?= =?UTF-8?q?leton=20index?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/cells.c | 59 +++------------------------------- src/builtins/select.c | 74 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 76 insertions(+), 57 deletions(-) diff --git a/src/builtins/cells.c b/src/builtins/cells.c index b5ea3bb2..c9060c43 100644 --- a/src/builtins/cells.c +++ b/src/builtins/cells.c @@ -219,9 +219,8 @@ NOINLINE B leading_axis_arith(FC2 fc2, B w, B x, usz* wsh, usz* xsh, ur mr) { // // fast special-case implementations -extern void (*const si_select_cells_bit_lt64)(u64*,u64*,usz,usz,usz); // from fold.c (fold.singeli) -extern usz (*const si_select_cells_byte)(void*,void*,usz,usz,u8); -static NOINLINE B select_cells(usz ind, B x, usz cam, usz k, bool leaf) { // ind {leaf? <∘⊑; ⊏}⎉¯k x; TODO probably can share some parts with takedrop_highrank and/or call ⊏? +B select_cells_single(usz ind, B x, usz cam, usz l, usz csz, bool leaf); // from select.c +static NOINLINE B select_cells(usz ind, B x, usz cam, usz k, bool leaf) { // ind {leaf? <∘⊑; ⊏}⎉¯k x ur xr = RNK(x); assert(xr>1 && k=7 || (xl<3 && xl>0)) { // generic case - MAKE_MUT_INIT(rm, ria, TI(x,elType)); MUTG_INIT(rm); - usz jump = l * csz; - usz xi = take*ind; - usz ri = 0; - for (usz i = 0; i < cam; i++) { - mut_copyG(rm, ri, x, xi, take); - xi+= jump; - ri+= take; - } - ra = mut_fp(rm); - } else if (xe==el_B) { - assert(take == 1); - SGet(x) - HArr_p rp = m_harrUv(ria); - for (usz i = 0; i < cam; i++) rp.a[i] = Get(x, i*l+ind); - NOGC_E; ra = (Arr*)rp.c; - } else { - void* rp = m_tyarrlbp(&ra, ewl, ria, el2t(xe)); - void* xp = tyany_ptr(x); - if (xl == 0) { - #if SINGELI - if (l < 64) si_select_cells_bit_lt64(xp, rp, cam, l, ind); - else - #endif - for (usz i=0; i=7 || (xl<3 && xl>0)) { // generic case + MAKE_MUT_INIT(rm, ria, TI(x,elType)); MUTG_INIT(rm); + usz jump = l * csz; + usz xi = take*ind; + usz ri = 0; + for (usz i = 0; i < cam; i++) { + mut_copyG(rm, ri, x, xi, take); + xi+= jump; + ri+= take; + } + ra = mut_fp(rm); + } else if (xe==el_B) { + assert(take == 1); + SGet(x) + HArr_p rp = m_harrUv(ria); + for (usz i = 0; i < cam; i++) rp.a[i] = Get(x, i*l+ind); + NOGC_E; ra = (Arr*)rp.c; + } else { + void* rp = m_tyarrlbp(&ra, ewl, ria, el2t(xe)); + void* xp = tyany_ptr(x); + if (xl == 0) { + #if SINGELI + if (l < 64) si_select_cells_bit_lt64(xp, rp, cam, l, ind); + else + #endif + for (usz i=0; iel_i8 : !elInt(ie)) { inds = num_squeeze(inds); ie = TI(inds,elType);