more efficient spreadBits{[8]u32, u8}

This commit is contained in:
dzaima 2022-09-08 21:51:25 +03:00
parent d3a1fee437
commit 2358436b89

View File

@ -58,7 +58,7 @@ def spreadBits{T==[32]u8, a:u32} = {
}
def spreadBits{T, a & vcount{T} <= width{eltype{T}} & w256u{T}} = {
b:= make{T, 1<<iota{vcount{T}}}
b == (b & broadcast{T, a})
b == (b & T~~broadcast{to_el{type{a}, T}, a}) # not just broadcast{T, a} so that if a is read from RAM, it can use the single instruction for broadcasting from RAM; the extra bits don't matter
}
def loadBatchBit{T, x:*u64, n:(Size)} = { # vector with type T with each element being either all 0s or 1s