diff --git a/src/builtins/arithm.c b/src/builtins/arithm.c index 15bea57b..d3a39640 100644 --- a/src/builtins/arithm.c +++ b/src/builtins/arithm.c @@ -11,11 +11,13 @@ static inline B arith_recm(BB2B f, B x) { return withFill(r, fx); } +void bit_negatePtr(u64* rp, u64* xp, usz count) { + for (usz i = 0; i < count; i++) rp[i] = ~xp[i]; +} B bit_negate(B x) { // consumes u64* xp = bitarr_ptr(x); u64* rp; B r = m_bitarrc(&rp, x); - usz ia = BIT_N(IA(x)); - for (usz i = 0; i < ia; i++) rp[i] = ~xp[i]; + bit_negatePtr(rp, xp, BIT_N(IA(x))); decG(x); return r; } diff --git a/src/builtins/sysfn.c b/src/builtins/sysfn.c index e5f692da..02de9688 100644 --- a/src/builtins/sysfn.c +++ b/src/builtins/sysfn.c @@ -5,6 +5,7 @@ #include "../core.h" #include "../utils/hash.h" +#include "../utils/calls.h" #include "../utils/file.h" #include "../utils/wyhash.h" #include "../utils/time.h" @@ -1228,7 +1229,7 @@ B bitop1(B f, B x, enum BitOp1 op, char* name) { } switch (op) { default: UD; case op_not: { - usz l = n/64; NOUNROLL for (usz i=0; i> q) & (rp[l]^~xp[l]); } break; case op_neg: switch (ow) { diff --git a/src/singeli/src/cmp.singeli b/src/singeli/src/cmp.singeli index 435c23a9..12ec9069 100644 --- a/src/singeli/src/cmp.singeli +++ b/src/singeli/src/cmp.singeli @@ -89,8 +89,8 @@ bitAA{bitop}(dst:*u64, wr:*void, xr:*void, len:Size) : void = { @forNZ (dst, w in *u64~~wr, x in *u64~~xr over _ to cdiv{len,64}) dst = bitop{w,x} } -not(dst:*u64, x:*u64, len:Size) : void = { am:=cdiv{len,64}; @forNZ (dst,x over _ to am) dst = ~x } -cpy(dst:*u64, x:*u64, len:Size) : void = { am:=cdiv{len,64}; @forNZ (dst,x over _ to am) dst = x } +not(dst:*u64, x:*u64, len:Size) : void = { am:=cdiv{len,64}; emit{void, 'bit_negatePtr', dst, x, am} } +cpy(dst:*u64, x:*u64, len:Size) : void = { am:=cdiv{len,64}; emit{void, 'memcpy', dst, x, am*8} } bitAS{op}(dst:*u64, wr:*void, x:u64, len:Size) : void = { # show{'bitAS'} xf:f64 = interp_f64{x} diff --git a/src/utils/calls.h b/src/utils/calls.h index 17d2e720..c9cc4d1b 100644 --- a/src/utils/calls.h +++ b/src/utils/calls.h @@ -27,3 +27,5 @@ CMP_DEF(le, AS); #define CMP_AA_IMM(FN, ELT, WHERE, WP, XP, LEN) CMP_AA_CALL(CMP_AA_FN(FN, ELT), WHERE, WP, XP, LEN) #define CMP_AS_IMM(FN, ELT, WHERE, WP, X, LEN) CMP_AS_CALL(CMP_AS_FN(FN, ELT), WHERE, WP, X, LEN) + +void bit_negatePtr(u64* rp, u64* xp, usz count); // count is number of u64-s \ No newline at end of file