use Singeli a==b instead of a=(b)

This commit is contained in:
dzaima 2025-02-04 23:01:10 +02:00
parent b12575722a
commit c792d47069
4 changed files with 10 additions and 10 deletions

View File

@ -154,7 +154,7 @@ def bitalign{{2,8,s}, 8, G if hasarch{'AVX512VBMI'}} = G{s, {a:V=[k](u8)} => {
def __shl{a:([16]u8), sh:([16]i8) if hasarch{'AARCH64'}} = a << [16]u8~~sh
def bitalign{{2,8,s}, 8, G if hasarch{'AARCH64'}} = G{s, {a:V=([16]u8)} => {
def bitalign{{2,8,s}, 8, G if hasarch{'AARCH64'}} = G{s, {a:V==[16]u8} => {
def {shuf1, shift1, shuf2, shift2} = makevtabs{16, xrange{2,8},
tup{u8, {s,r} => r *s>>3}, tup{i8, {s,r} => - r *s%8},
tup{u8, {s,r} => (r+1)*s>>3}, tup{i8, {s,r} => s - (r+1)*s%8},
@ -197,7 +197,7 @@ def bitalign{8, {2,8,d}, G if hasarch{'AARCH64'}} = {
tup{i8, {d,r} => select{props{d},2}},
}
def run{do_blend}{a:V=([16]u8)} = {
def run{do_blend}{a:V==[16]u8} = {
def shuf1 = shuf0 + V**1
def shift1 = shift0 + [16]i8**cast_i{i8,d}
def b = a & V**cast_i{u8, tail{d}}

View File

@ -31,7 +31,7 @@ def arithChk2{F, M, w:T, x:T if is_s{T} and (same{F,__add} or same{F,__sub})} =
}
# ×
def arithChk2{F=(__mul), M, w:T=[_](i8), x:T if hasarch{'X86_64'}} = {
def arithChk2{F==__mul, M, w:T=[_](i8), x:T if hasarch{'X86_64'}} = {
def wp = mzip128{w, T ~~ (T**0 > w)}
def xp = mzip128{x, T ~~ (T**0 > x)}
def rp = each{__mul, wp, xp}
@ -44,12 +44,12 @@ def arithChk2{F=(__mul), M, w:T=[_](i8), x:T if hasarch{'X86_64'}} = {
tup{packQ{rp}, tup{'and_some', RU~~tree_fold{|, bad}, RU**0xff80}}
}
}
def arithChk2{F=(__mul), M, w:T=[_](i16), x:T if hasarch{'X86_64'}} = {
def arithChk2{F==__mul, M, w:T=[_](i16), x:T if hasarch{'X86_64'}} = {
rl:= __mul{w,x}
rh:= mulh{w,x}
tup{rl, tup{'anyne', rh, rl>>15}}
}
def arithChk2{F=(__mul), M, w:T=[_](i32), x:T if hasarch{'X86_64'}} = {
def arithChk2{F==__mul, M, w:T=[_](i32), x:T if hasarch{'X86_64'}} = {
max:= re_el{f32, (ty_u{T})**0x4efffffe}
def cf32{x:X} = emit{re_el{f32,X}, tern{T==[8]i32, '_mm256_cvtepi32_ps', '_mm_cvtepi32_ps'}, x}
f32mul:= cf32{w} * cf32{x}
@ -66,7 +66,7 @@ def arithChk2{F=(__mul), M, w:T=[_](i32), x:T if hasarch{'X86_64'}} = {
# tup{packQQ{each{{v} => v & T2**0xFFFFFFFF, rp}}, tup{'any_hom', tree_fold{|,bad}}} this doesn't use M
}
def arithChk2{F=(__mul), M, w:T=[_]E, x:T if hasarch{'AARCH64'}} = {
def arithChk2{F==__mul, M, w:T=[_]E, x:T if hasarch{'AARCH64'}} = {
def {rl, rh} = pack{...mulw_split{w, x}}
tup{rl, tup{'any_hom', M{rh != (rl >> (width{E}-1))}}}
}

View File

@ -148,11 +148,11 @@ def hom_to_int{...vs if all_type{nvec,vs} and not all_type{nvecu,vs}} = hom_to_i
def hom_to_int{x:V=[k]E if nvecu{V} and width{E}>=k} = {
trunc_bits{k, fold_add{x & make{V, 1<<iota{k}}}}
}
def hom_to_int{x:V=([16]u8)} = {
def hom_to_int{x:V==[16]u8} = {
t:= [8]u16~~sel{[16]u8, x, make{[16]u8, tr_iota{3,0,1,2}}}
fold_add{t & make{[8]u16, (1<<iota{8})*0x0101}}
}
def hom_to_int{a:V,b:V=([16]u8)} = {
def hom_to_int{a:V,b:V==[16]u8} = {
m:= make{[16]u8, 1<<(iota{16}&7)}
s:= make{[16]u8, (range{16}>>2) | ((range{16}&3)<<2)}
# fold_add{addpw{addpw{addp{a&m, b&m}}}<<make{[4]u32,iota{4}*8}}
@ -162,7 +162,7 @@ def hom_to_int{a:V,b:V=([16]u8)} = {
# t:= shrm{l, 4, h} & make{[16]u8, (1<<(range{16}>>2)) * 0x11}
# fold_add{[4]u32~~t}
}
def hom_to_int{a:V,b:V,c:V,d:V=([16]u8)} = {
def hom_to_int{a:V,b:V,c:V,d:V==[16]u8} = {
m:= make{[16]u8, 1<<(iota{16}&7)}
t1:= addp{a & m, b & m}
t2:= addp{c & m, d & m}

View File

@ -378,7 +378,7 @@ def get_boolvec_writer{V, r, nw} = {
}
tup{output, check_done, flush}
}
def get_boolvec_writer{T=(u64), r:*T, nw} = {
def get_boolvec_writer{T==u64, r:*T, nw} = {
def done = makelabel{}
j:usz = 0
def output{rw} = {