Performs the supplied binary arithmetic `op` on two values, either vector or scalar.
(
x: DataValue,
y: DataValue,
vector_type: types::Type,
op: F,
)
| 1565 | |
| 1566 | /// Performs the supplied binary arithmetic `op` on two values, either vector or scalar. |
| 1567 | fn binary_arith<F>( |
| 1568 | x: DataValue, |
| 1569 | y: DataValue, |
| 1570 | vector_type: types::Type, |
| 1571 | op: F, |
| 1572 | ) -> ValueResult<DataValue> |
| 1573 | where |
| 1574 | F: Fn(DataValue, DataValue) -> ValueResult<DataValue>, |
| 1575 | { |
| 1576 | let arg0 = extractlanes(&x, vector_type)?; |
| 1577 | let arg1 = extractlanes(&y, vector_type)?; |
| 1578 | |
| 1579 | let result = arg0 |
| 1580 | .into_iter() |
| 1581 | .zip(arg1) |
| 1582 | .map(|(lhs, rhs)| Ok(op(lhs, rhs)?)) |
| 1583 | .collect::<ValueResult<SimdVec<DataValue>>>()?; |
| 1584 | |
| 1585 | vectorizelanes(&result, vector_type) |
| 1586 | } |
| 1587 | |
| 1588 | /// Performs the supplied pairwise arithmetic `op` on two SIMD vectors, where |
| 1589 | /// pairs are formed from adjacent vector elements and the vectors are |
no test coverage detected