The replace_lane SIMD conversion instruction replaces the specified lane of a v128 value interpretation with a new value and returns the resulting v128 value interpretation.
(module
(import "console" "log" (func $log (param f64)))
(func $main
v128.const f64x2 1200000 3456789
f64.const 777777
f64x2.replace_lane 1
f64x2.extract_lane 1
call $log ;; log the result
)
(start $main)
)WebAssembly.instantiateStreaming(fetch("{%wasm-url%}"), { console });value_type.replace_lane index
value_typeThe type of value the instruction is being run on. The following v128 value interpretations support replace_lane:
i8x16i16x8i32x4i64x2f32x4f64x2replace_laneThe replace_lane instruction. Must always be included after the value_type and a period (.).
indexThe index of the lane that you want to replace.
[input, replace_value] -> [output]
inputThe input v128 value interpretation.
replace_valueThe value that you want to replace the lane with.
outputThe output v128 value interpretation.
| Instruction | Binary format | Example text => binary |
|---|---|---|
i8x16.replace_lane | 0xfd 23:u32 l:lane_idx | i8x16.replace_lane 3 => 0xfd 0x17 0x03 |
i16x8.replace_lane | 0xfd 26:u32 l:lane_idx | i16x8.replace_lane 3 => 0xfd 0x1a 0x03 |
i32x4.replace_lane | 0xfd 28:u32 l:lane_idx | i32x4.replace_lane 3 => 0xfd 0x1c 0x03 |
i64x2.replace_lane | 0xfd 30:u32 l:lane_idx | i64x2.replace_lane 1 => 0xfd 0x1e 0x01 |
f32x4.replace_lane | 0xfd 32:u32 l:lane_idx | f32x4.replace_lane 3 => 0xfd 0x20 0x03 |
f64x2.replace_lane | 0xfd 34:u32 l:lane_idx | f64x2.replace_lane 1 => 0xfd 0x22 0x01 |