extmul_high_i16x8_s: Wasm SIMD arithmetic instruction
The extmul_high_i16x8_s SIMD arithmetic instruction takes lanes 4–7 of two signed v128 i16x8 value interpretations, multiplies the values in the corresponding lanes, and outputs the result of those operations into an i32x4 value interpretation.
Try it
(module
(import "console" "log" (func $log (param i32)))
(func $main
v128.const i16x8 3 3 3 3 6 6 6 6
v128.const i16x8 2 2 2 2 4 4 4 4
i32x4.extmul_high_i16x8_s
i32x4.extract_lane 3
call $log ;; log the result
)
(start $main)
)
WebAssembly.instantiateStreaming(fetch("{%wasm-url%}"), { console });
In the above example, lanes 4–7 of the two i16x8 input values are multiplied together and the products output as an i32x4. Lane 4 of the first input is multiplied by lane 4 of the second input, and the product becomes lane 0 of the output, and so on. As a result, each lane of the output contains the value 24 (6 * 4).
The extmul_high_i16x8_s instruction is a more performant equivalent to passing the results of two extend_high_i16x8_s instructions into a mul instruction.
In other words:
(i32x4.extmul_high_i16x8_s
(input1)
(input2)
)
is equivalent to
(i32x4.mul
(i32x4.extend_high_i16x8_s
(input1)
)
(i32x4.extend_high_i16x8_s
(input2)
)
)
Syntax
i32x4.extmul_high_i16x8_s
i32x4.extmul_high_i16x8_s-
The
i32x4.extmul_high_i16x8_sinstruction.
Type
[input1, input2] -> [output]
Binary encoding
| Instruction | Binary format | Example text => binary |
|---|---|---|
i32x4.extmul_high_i16x8_s |
0xfd 189:u32 |
i32x4.extmul_high_i16x8_s => 0xfd 0xbd 0x01 |