shr_s: Wasm SIMD bitwise instruction
The shr_s SIMD bitwise instruction shifts the bits in each lane of a v128 value interpretation to the right by the same specified amount, outputting signed values. This is an arithmetic right shift.
Try it
(module
(import "console" "log" (func $log (param i32)))
(func $main
v128.const i32x4 8 16 32 64
i32.const 3
i32x4.shr_s
i32x4.extract_lane 3
call $log ;; log the result
)
(start $main)
)
WebAssembly.instantiateStreaming(fetch("{%wasm-url%}"), { console });
Syntax
value_type.shr_s
value_type-
The type of value the instruction is being run on. The following
v128value interpretations supportshr_s:i8x16i16x8i32x4i64x2
shr_s-
The
shr_sinstruction. Must always be included after thevalue_typeand a period (.).
Type
[input, shift_value] -> [output]
input-
The input
v128value interpretation. shift_value-
The value that you want to shift the lanes by.
output-
The output
v128value interpretation.
Binary encoding
| Instruction | Binary format | Example text => binary |
|---|---|---|
i8x16.shr_s |
0xfd 108:u32 |
i8x16.shr_s => 0xfd 0x6c |
i16x8.shr_s |
0xfd 140:u32 |
i16x8.shr_s => 0xfd 0x8c 0x01 |
i32x4.shr_s |
0xfd 172:u32 |
i32x4.shr_s => 0xfd 0xac 0x01 |
i64x2.shr_s |
0xfd 204:u32 |
i64x2.shr_s => 0xfd 0xcc 0x01 |