GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

extract_lane: Wasm SIMD extract instruction

The extractlane SIMD extract instruction extracts the value contained within the specified lane of a v128 value interpretation.

The **`extract_lane`** [SIMD extract instruction](/docs/WebAssembly/Reference/SIMD/extract) extracts the value contained within the specified lane of a [`v128`](/docs/WebAssembly/Reference/Value_types/v128) value interpretation.

tabbed-taller

```wat interactive-example
(module
(import "console" "log" (func $log (param f32)))
(func $main
;; load two SIMD values onto the stack
(v128.const f32x4 0x9 0xa 0xb 0xc)
(v128.const f32x4 0x10 0x11 0x12 0x13)

f32x4.add ;; add the two values
f32x4.extract_lane 0 ;; Extract a float value from the result
call $log ;; log the result
)
(start $main)
)
```

```js interactive-example
WebAssembly.instantiateStreaming(fetch("{%wasm-url%}"), { console });
```

## Syntax

```plain
value_type.extract_lane
```

- `value_type`
- : The type of value the instruction is being run on. The following [`v128`](/docs/WebAssembly/Reference/Value_types/v128) value interpretations support `extract_lane`:
- `i32x4`
- `i64x2`
- `f32x4`
- `f64x2`
- `extract_lane`
- : The `extract_lane` instruction. Must always be included after the `value_type` and a period (`.`).

### Type

```plain
[input, lane] -> [output]
```

- `input`
- : The `v128` value interpretation you want to extract a lane from.
- `lane`
- : The index of the lane whose value you wish to extract, for example `0`.
- `output`
- : The value extracted from the lane.

### Binary encoding

| Instruction | Binary format | Example text => binary |
| -------------------- | ------------------------ | ------------------------------------------ |
| `i32x4.extract_lane` | `0xfd 27:u32 l:lane_idx` | `i32x4.extract_lane 3` => `0xfd 0x1b 0x03` |
| `i64x2.extract_lane` | `0xfd 29:u32 l:lane_idx` | `i64x2.extract_lane 1` => `0xfd 0x1d 0x01` |
| `f32x4.extract_lane` | `0xfd 31:u32 l:lane_idx` | `f32x4.extract_lane 3` => `0xfd 0x1f 0x03` |
| `f64x2.extract_lane` | `0xfd 33:u32 l:lane_idx` | `f64x2.extract_lane 1` => `0xfd 0x21 0x01` |

## Specifications

## Browser compatibility

## See also

- [`replace_lane`](/docs/WebAssembly/Reference/SIMD/conversion/replace_lane)

source: MDN Web Docs mirror · page

Cite this

"extract_lane: Wasm SIMD extract instruction". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/WebAssembly/Reference/SIMD/extract/extract_lane

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·