Selects values from the two vector operands, combining them together to result in a new vector 1.
The lanes to select from are indicated using the immediates, with indices
$$ \mathsf{i8x16.shuffle} \enspace \mathsf{i5}_1, \mathsf{i5}2, ..., \mathsf{i5}{16} \enspace ( a: \mathsf{v128}, b: \mathsf{v128} ) \to \mathsf{v128} $$
Opcode | Instruction | Immediates | Stack Arity |
---|---|---|---|
0xFD 13 |
i8x16.shuffle |
$\mathsf{i5}_1, \mathsf{i5}2, ..., \mathsf{i5}{16}$ |
;; Create two vectors containing the values
v128.const i8x16 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31
v128.const i8x16 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32
;; The immediates define the ordered indices to select from the two vectors
i8x16.shuffle 0 16 1 17 2 18 3 19 4 20 5 21 6 22 7 23
;; The resulting vector looks like this:
;; [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ]
Footnotes
-
WebAssembly Core Specification, Execution, Vector Instructions, i8x16.shuffle - https://webassembly.github.io/spec/core/bikeshed/#-mathsfi8x16hrefsyntax-instr-vecmathsfshufflexast ↩ ↩2