#Is there a reason that the fourth parameter 'mask' of @shuffle is a comptime?
1 messages · Page 1 of 1 (latest)
It's because of the way the vector instructions work
because most architectures that have shuffle require it as an immediate, not a register
The mask is encoded into the instruction itself
So it can't come from a runtime value (unless you do some horribly cursed self-modifying stuff, I guess)
x86 SSE3 with pshufb and arm neon with tbl/tbx do shuffles and take a runtime mask
it's less about "can it be done on some platforms" and more about "can it be done consistently on every platform we want to support"
ok, i see. it's directly translated to the SIMD opcode. i guess it's for fixed predetermined selectors.
its a well known law that simd only matterns on sse, neon and maybe powerpc/wasm 
sure, and sse 1 and 2 don't support runtime masks :)
ah yea baseline is pentium4
i guess it becomes a problem of generating vector a and vector b dynamically to fit the constant selector pattern 'mask'.
yes, but also zig supports i386, which can potentially have no sse at all
just dreaming of certain intrinsic support which compile-errors on unsupported platforms (i.e. gather/scatter). But in this case, thats the job of a library
this problem aside, zig has the best simd support i've seen so far. the vector abstraction in the language really simplifies the simd usage. miles ahead of other languages.