MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / binary_pairwise

Function binary_pairwise

cranelift/interpreter/src/step.rs:1591–1610  ·  view source on GitHub ↗

Performs the supplied pairwise arithmetic `op` on two SIMD vectors, where pairs are formed from adjacent vector elements and the vectors are concatenated at the end.

(
    x: DataValue,
    y: DataValue,
    vector_type: types::Type,
    op: F,
)

Source from the content-addressed store, hash-verified

1589/// pairs are formed from adjacent vector elements and the vectors are
1590/// concatenated at the end.
1591fn binary_pairwise<F>(
1592 x: DataValue,
1593 y: DataValue,
1594 vector_type: types::Type,
1595 op: F,
1596) -> ValueResult<DataValue>
1597where
1598 F: Fn(DataValue, DataValue) -> ValueResult<DataValue>,
1599{
1600 let arg0 = extractlanes(&x, vector_type)?;
1601 let arg1 = extractlanes(&y, vector_type)?;
1602
1603 let result = arg0
1604 .chunks(2)
1605 .chain(arg1.chunks(2))
1606 .map(|pair| op(pair[0].clone(), pair[1].clone()))
1607 .collect::<ValueResult<SimdVec<DataValue>>>()?;
1608
1609 vectorizelanes(&result, vector_type)
1610}
1611
1612fn bitselect(c: DataValue, x: DataValue, y: DataValue) -> ValueResult<DataValue> {
1613 let mask_x = DataValueExt::and(c.clone(), x)?;

Callers 1

stepFunction · 0.85

Calls 5

extractlanesFunction · 0.85
vectorizelanesFunction · 0.85
chainMethod · 0.80
mapMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected