move bit_sum to fold.c
This commit is contained in:
parent
a439c64e85
commit
9984d720c9
@ -293,6 +293,13 @@ B fold_c2(Md1D* d, B w, B x) { B f = d->f;
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NOINLINE i64 bit_sum(u64* x, u64 am) {
|
||||||
|
i64 r = 0;
|
||||||
|
for (u64 i = 0; i < (am>>6); i++) r+= POPC(x[i]);
|
||||||
|
if (am&63) r+= POPC(x[am>>6]<<(64-am & 63));
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
u64 usum(B x) { // doesn't consume; will error on non-integers, or elements <0, or if sum overflows u64
|
u64 usum(B x) { // doesn't consume; will error on non-integers, or elements <0, or if sum overflows u64
|
||||||
assert(isArr(x));
|
assert(isArr(x));
|
||||||
u64 r = 0;
|
u64 r = 0;
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include "../utils/talloc.h"
|
#include "../utils/talloc.h"
|
||||||
#include "../builtins.h"
|
#include "../builtins.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
bool please_tail_call_err = true;
|
bool please_tail_call_err = true;
|
||||||
|
|
||||||
@ -360,12 +361,6 @@ NOINLINE void thrF(char* p, ...) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
i64 bit_sum(u64* x, u64 am) {
|
|
||||||
i64 r = 0;
|
|
||||||
for (u64 i = 0; i < (am>>6); i++) r+= POPC(x[i]);
|
|
||||||
if (am&63) r+= POPC(x[am>>6]<<(64-am & 63));
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
usz depthF(B x) { // doesn't consume
|
usz depthF(B x) { // doesn't consume
|
||||||
u64 r = 0;
|
u64 r = 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user