move length zero check outside singeli

This commit is contained in:
dzaima 2021-10-25 13:57:45 +03:00
parent 4e17e28d4a
commit 798f6e9e17
2 changed files with 17 additions and 17 deletions

View File

@ -4,7 +4,8 @@
static NOINLINE void fillBits(u64* dst, u64 sz, bool v) {
u64 x = 0-(u64)v;
for (usz i = 0; i < (sz+63)/64; i++) dst[i] = x;
u64 am = (sz+63)/64; assert(am>0);
for (usz i = 0; i < am; i++) dst[i] = x;
}
static NORETURN void cmp_err() { thrM("Invalid comparison"); }
@ -34,7 +35,7 @@ static void* tyany_ptr(B x) {
return IS_SLICE(t)? c(TySlice,x)->a : c(TyArr,x)->a;
}
#define AL(X) u64* rp; B r = m_bitarrc(&rp, X); usz ria=a(r)->ia;
#define AL(X) u64* rp; B r = m_bitarrc(&rp, X); usz ria=a(r)->ia
#define CMP_IMPL(CHR, NAME, RNAME, PNAME, L, R, OP, FC, CF, BX) \
if (isF64(w)&isF64(x)) return m_i32(w.f OP x.f); \
if (isC32(w)&isC32(x)) return m_i32(w.u OP x.u); \
@ -48,15 +49,17 @@ static void* tyany_ptr(B x) {
if (we==el_MAX) goto end; \
w=tw; x=tx; \
} \
AL(x) \
lut_avx2_##PNAME##AA[we](rp, (u8*)tyany_ptr(L), (u8*)tyany_ptr(R), ria); \
AL(x); \
if (ria) lut_avx2_##PNAME##AA[we](rp, (u8*)tyany_ptr(L), (u8*)tyany_ptr(R), ria); \
dec(w);dec(x); return r; \
} \
} else { \
AL(w) lut_avx2_##NAME##AS[we](rp, (u8*)tyany_ptr(w), x.u, ria); dec(w); return r; \
} else goto end; \
} \
} else if (isArr(x)) { u8 xe = TI(x,elType); if (xe==el_B) goto end; \
AL(x) lut_avx2_##RNAME##AS[xe](rp, (u8*)tyany_ptr(x), w.u, ria); dec(x); return r; \
AL(w); \
if (ria) lut_avx2_##NAME##AS [we](rp, (u8*)tyany_ptr(w), x.u, ria); \
dec(w); return r; \
} else if (isArr(x)) { u8 xe = TI(x,elType); if (xe==el_B) goto end; AL(x); \
if (ria) lut_avx2_##RNAME##AS[xe](rp, (u8*)tyany_ptr(x), w.u, ria); \
dec(x); return r; \
} \
if (isF64(w)&isC32(x)) return m_i32(FC); \
if (isC32(w)&isF64(x)) return m_i32(CF); \

View File

@ -73,9 +73,9 @@ def any2bit{VT, unr, op, wS, wV, xS, xV, dst:*u64, len:(Size)} = {
xi:Size = 0
ri:Size = 0
def bam = vcount{VT}*unr
len:Size = cdiv{len,bam}
assert{len!=0}
while (ri < len) {
am:Size = cdiv{len,bam}
assert{am>0}
while (ri < am) {
r:u64 = 0
@unroll (j from 0 to unr) r = r | (cast_i{u64, getmask{op{wV{xi+j}, xV{xi+j}}}} << (j*vcount{VT}))
b_set{bam, dst, ri, r}
@ -84,14 +84,12 @@ def any2bit{VT, unr, op, wS, wV, xS, xV, dst:*u64, len:(Size)} = {
}
}
aa2bit{VT, unr, op}(dst:*u64, wr:*u8, xr:*u8, len:Size) : void = {
if (len==0) return{}
wv:= cast_vp{VT, wr}; ws:= cast_p{*eltype{VT}, wr}
xv:= cast_vp{VT, xr}; xs:= cast_p{*eltype{VT}, xr}
any2bit{VT, unr, op, {i}=>load{ws,i}, {i}=>vload{wv,i}, {i}=>load{xs,i}, {i}=>vload{xv,i}, dst, len}
}
as2bit{VT, unr, op}(dst:*u64, wr:*u8, x:u64, len:Size) : void = { show{VT,unr,fmt{op}}
if (len==0) return{}
wv:= cast_vp{VT, wr}; ws:= cast_p{*eltype{VT}, wr}
xv:= broadcast{VT, pathAS{dst, len, eltype{VT}, op, x}}
any2bit{VT, unr, op, {i}=>load{ws,i}, {i}=>vload{wv,i}, {i}=>x, {i}=>xv, dst, len}
@ -103,11 +101,10 @@ bitAA{bitop}(dst:*u64, wr:*u8, xr:*u8, len:Size) : void = {
@for (dst,ws,xs over _ from 0 to cdiv{len,64}) dst = bitop{ws,xs}
}
not(dst:*u64, x:*u64, len:Size) : void = { @for (dst,x over _ from 0 to cdiv{len,64}) dst = ~x }
cpy(dst:*u64, x:*u64, len:Size) : void = { @for (dst,x over _ from 0 to cdiv{len,64}) dst = x }
not(dst:*u64, x:*u64, len:Size) : void = { am:=cdiv{len,64}; assert{am>0}; @for (dst,x over _ from 0 to am) dst = ~x }
cpy(dst:*u64, x:*u64, len:Size) : void = { am:=cdiv{len,64}; assert{am>0}; @for (dst,x over _ from 0 to am) dst = x }
bitAS{op}(dst:*u64, wr:*u8, x:u64, len:Size) : void = { show{'bitAS'}
if (len==0) return{}
xf:f64 = interp_f64{x}
r0:u1 = op{0,xf}
r1:u1 = op{1,xf}