3 ms·
SIMD.js's shuffle instructions closely resemble LLVM's shuffle instructions, and LLVM also require shuffle indices to be constant, so this isn't restriction isn
by sunfish 11y ago
SIMD.js's shuffle instructions closely resemble LLVM's shuffle instructions, and LLVM also require shuffle indices to be constant, so this isn't restriction isn't unique to SIMD.js. Also, x86's shuffle situation is much more involved than your post here acknowledges; it includes shufps, shufpd, movlhps, movlhpd, movhlps, movhlpd, unpcklps, unpcklpd, unpckhps, unpckhpd, movss, movsd, and more, and all of these are effectively constant shuffle masks.
I agree that there's more we can do here, and there are some interesting questions if we want to abstract over pshufb and VTBL and so on. Fortunately, SIMD.js is an evolving API and we can add things to it.
- kragen 11y agoOh, I didn't realize SIMD.js required the shuffle indices to be constant in order to generate efficient code. In that case, sure, you can generate efficient code and take advantage of the panoply of special-purpose shunting instructions you mention, and writing and reading the SIMD.js code is even going to be easier than SSE. Thank you for correcting my understanding!