dot_i16x8_s: Wasm SIMD arithmetic instruction
The dot_i16x8_s SIMD arithmetic instruction performs a dot product calculation on two signed v128 i16x8 value interpretations. The corresponding lanes of the input values are multiplied together, then each adjacent pair of products are added together. The four results of these additions are output as an i32x4 value interpretation.
Try it
(module
(import "console" "log" (func $log (param i32)))
(func $main
v128.const i16x8 4 6 16 8 23 65 82 9
v128.const i16x8 0 25 2 30 2 34 45 80
i32x4.dot_i16x8_s
i32x4.extract_lane 3
call $log ;; log the result
)
(start $main)
)
WebAssembly.instantiateStreaming(fetch("{%wasm-url%}"), { console });
In the above example, the corresponding lanes of each input are multiplied together to create eight intermediate values:
input1 4 6 16 8 23 65 82 9 input2 0 25 2 30 2 34 45 80 product 0 150 32 240 46 2210 3690 720
Each adjacent pair of products is then added, and the result output onto the stack as an i32x4 containing the following values:
150 272 2256 4410
Syntax
i32x4.dot_i16x8_s
i32x4.dot_i16x8_s-
The
i32x4.dot_i16x8_sinstruction.
Type
[input1, input2] -> [output]
Binary encoding
| Instruction | Binary format | Example text => binary |
|---|---|---|
i32x4.dot_i16x8_s |
0xfd 186:u32 |
i32x4.dot_i16x8_s => 0xfd 0xba 0x01 |