MDN / extadd_pairwise_i8x16_s: Wasm SIMD arithmetic instruction
MDN / extadd_pairwise_i8x16_s: Wasm SIMD arithmetic instruction
The extadd_pairwise_i8x16_s SIMD arithmetic instruction adds each adjacent pair of lanes of a signed v128 i8x16 value interpretation, outputting the results into an i16x8 value interpretation.
(module
(import "console" "log" (func $log (param i32)))
(func $main
v128.const i8x16 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4
i16x8.extadd_pairwise_i8x16_s
i16x8.extract_lane_s 7
call $log ;; log the result
)
(start $main)
)
WebAssembly.instantiateStreaming(fetch("{%wasm-url%}"), { console });
In the above example, each adjacent pair of lanes contains the values 2 and 4. The extadd_pairwise_i8x16_s instruction adds each pair together, resulting in the 8 lanes of the output i16x8 value all containing the value 6.
Syntax
i16x8.extadd_pairwise_i8x16_s
i16x8.extadd_pairwise_i8x16_s: The
i16x8.extadd_pairwise_i8x16_sinstruction.
Type
[input] -> [output]
input: The input
v128i8x16value interpretation.
output: The output
v128i16x8value interpretation.
Binary encoding
InstructionBinary formatExample text => binaryi16x8.extadd_pairwise_i8x16_s0xfd 124:u32i16x8.extadd_pairwise_i8x16_s => 0xfd 0x7c