diff --git a/src/utils/bits.c b/src/utils/bits.c index 78c35a2a..b13fa218 100644 --- a/src/utils/bits.c +++ b/src/utils/bits.c @@ -121,6 +121,59 @@ FORCE_INLINE void ab_add(ABState* state, u64 val, ux count) { // assumes bits pa +NOINLINE void bitnarrow(void* rp, ux rcsz, void* xp, ux xcsz, ux cam) { // for now assumes the bits to be dropped are zero, xcsz is a multiple of 8, and that there's at most 63 padding bits + assert((xcsz&7) == 0 && rcsz>6; // full u64 count per cell in x + u64 msk = (1ull<<(rcsz&63))-1; + for (ux i = 0; i < cam; i++) { + for (ux j = 0; j < rfu64; j++) ab_add(&ab, loadu_u64(j + (u64*)xp), 64); + ab_add(&ab, loadu_u64(rfu64 + (u64*)xp)&msk, rcsz&63); + rp = (rcsz>>6) + (u64*)rp; + xp = (xcsz>>3) + (u8*)xp; + } + } + ab_done(ab); +} + NOINLINE void bitwiden(void* rp, ux rcsz, void* xp, ux xcsz, ux cam) { // for now assumes rcsz is either a multiple of 64, or one of 8,16,32 assert(rcsz > xcsz && ((rcsz&63) == 0 || rcsz==8 || rcsz==16 || rcsz==32)); @@ -249,57 +302,7 @@ B narrowWidenedBitArr(B x, ur axis, ur cr, usz* csh) { // for now assumes the bi shcpy(rsh, SH(x), axis); shcpy(rsh+axis, csh, cr); if (PIA(r)==0) goto decG_ret; - - u8* xp = tyany_ptr(x); - // FILL_TO(rp, el_bit, 0, m_f64(1), PIA(r)); - ABState ab = ab_new(rp); - if (xcsz<=64 && (xcsz&(xcsz-1)) == 0) { - #if FAST_PDEP - if (xcsz<32) { - assert(xcsz==8 || xcsz==16); - bool c8 = xcsz==8; - u64 tmsk = (1ull<>6; // full u64 count per cell in x - u64 msk = (1ull<<(ocsz&63))-1; - for (ux i = 0; i < cam; i++) { - for (ux j = 0; j < rfu64; j++) ab_add(&ab, loadu_u64(j + (u64*)xp), 64); - ab_add(&ab, loadu_u64(rfu64 + (u64*)xp)&msk, ocsz&63); - rp+= ocsz>>6; - xp+= xcsz>>3; - } - } - ab_done(ab); + bitnarrow(rp, ocsz, tyany_ptr(x), xcsz, cam); decG_ret:; decG(x); return taga(r);