cmp C cleanup, assert length!=0 before while
This commit is contained in:
parent
f8798affc4
commit
4717023167
@ -38,8 +38,6 @@ static void* tyany_ptr(B x) {
|
||||
#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); \
|
||||
if (isF64(w)&isC32(x)) return m_i32(FC); \
|
||||
if (isC32(w)&isF64(x)) return m_i32(CF); \
|
||||
if (isArr(w)) { u8 we = TI(w,elType); \
|
||||
if (we==el_B) goto end; \
|
||||
if (isArr(x)) { u8 xe = TI(x,elType); \
|
||||
@ -52,18 +50,14 @@ static void* tyany_ptr(B x) {
|
||||
} \
|
||||
AL(x) \
|
||||
lut_avx2_##PNAME##AA[we](rp, tyany_ptr(L), tyany_ptr(R), ria); \
|
||||
dec(w);dec(x); return r; \
|
||||
} \
|
||||
} else { AL(w) \
|
||||
/*print(w);printf("@%d "CHR" ",we);print(x);printf(": ");*/ \
|
||||
lut_avx2_##NAME##AS[we](rp, tyany_ptr(w), x.u, ria); \
|
||||
/*print(r);putchar('\n');*/ \
|
||||
dec(w); return r; \
|
||||
} \
|
||||
} else if (isArr(x)) { u8 xe = TI(x,elType); if (xe==el_B) goto end; AL(x) \
|
||||
/*print(x);printf(" "CHR" ");print(w);printf("@%d: ", xe);*/ \
|
||||
lut_avx2_##RNAME##AS[xe](rp, tyany_ptr(x), w.u, ria); \
|
||||
/*print(r);putchar('\n');*/ \
|
||||
dec(x); return r; \
|
||||
} \
|
||||
dec(w);dec(x); return r; \
|
||||
} \
|
||||
} else { \
|
||||
AL(w) lut_avx2_##NAME##AS[we](rp, 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) lut_avx2_##RNAME##AS[xe](rp, 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); \
|
||||
end:;
|
||||
|
||||
@ -3,6 +3,7 @@ include 'arch/c'
|
||||
def cdiv{a,b} = (a+b-1)/b
|
||||
def rare{x:u1} = emit{u1, '__builtin_expect', x, 0}
|
||||
def isunsigned{T} = isint{T} & ~issigned{T}
|
||||
def assert{x:u1} = emit{void, 'si_assert', x}
|
||||
|
||||
def unroll{vars,begin,end,block & match{kind{begin},'number'} & match{kind{end},'number'}} = {
|
||||
def f{i,l & i==l} = 0
|
||||
@ -21,4 +22,4 @@ def for{vars,begin,end,block} = {
|
||||
}
|
||||
def maxvalue{T & T==u8 } = 0xff
|
||||
def maxvalue{T & T==u16} = 0xffff
|
||||
def maxvalue{T & T==u32} = 0xffffffff
|
||||
def maxvalue{T & T==u32} = 0xffffffff
|
||||
|
||||
@ -78,6 +78,7 @@ def any2bit{VT, unr, op, wS, wV, xS, xV, dst:*u64, len:(Size)} = {
|
||||
ri:Size = 0
|
||||
def bam = vcount{VT}*unr
|
||||
len:Size = cdiv{len,bam}
|
||||
assert{len!=0}
|
||||
while (ri < len) {
|
||||
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}))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user