Compare two values using the given integer condition `code`.
(
ctrl_ty: types::Type,
code: IntCC,
left: &DataValue,
right: &DataValue,
)
| 1395 | |
| 1396 | /// Compare two values using the given integer condition `code`. |
| 1397 | fn icmp( |
| 1398 | ctrl_ty: types::Type, |
| 1399 | code: IntCC, |
| 1400 | left: &DataValue, |
| 1401 | right: &DataValue, |
| 1402 | ) -> ValueResult<DataValue> { |
| 1403 | let cmp = |bool_ty: types::Type, |
| 1404 | code: IntCC, |
| 1405 | left: &DataValue, |
| 1406 | right: &DataValue| |
| 1407 | -> ValueResult<DataValue> { |
| 1408 | Ok(DataValueExt::bool( |
| 1409 | match code { |
| 1410 | IntCC::Equal => left == right, |
| 1411 | IntCC::NotEqual => left != right, |
| 1412 | IntCC::SignedGreaterThan => left > right, |
| 1413 | IntCC::SignedGreaterThanOrEqual => left >= right, |
| 1414 | IntCC::SignedLessThan => left < right, |
| 1415 | IntCC::SignedLessThanOrEqual => left <= right, |
| 1416 | IntCC::UnsignedGreaterThan => { |
| 1417 | left.clone().into_int_unsigned()? > right.clone().into_int_unsigned()? |
| 1418 | } |
| 1419 | IntCC::UnsignedGreaterThanOrEqual => { |
| 1420 | left.clone().into_int_unsigned()? >= right.clone().into_int_unsigned()? |
| 1421 | } |
| 1422 | IntCC::UnsignedLessThan => { |
| 1423 | left.clone().into_int_unsigned()? < right.clone().into_int_unsigned()? |
| 1424 | } |
| 1425 | IntCC::UnsignedLessThanOrEqual => { |
| 1426 | left.clone().into_int_unsigned()? <= right.clone().into_int_unsigned()? |
| 1427 | } |
| 1428 | }, |
| 1429 | ctrl_ty.is_vector(), |
| 1430 | bool_ty, |
| 1431 | )?) |
| 1432 | }; |
| 1433 | |
| 1434 | let dst_ty = ctrl_ty.as_truthy(); |
| 1435 | let left = extractlanes(left, ctrl_ty)?; |
| 1436 | let right = extractlanes(right, ctrl_ty)?; |
| 1437 | |
| 1438 | let res = left |
| 1439 | .into_iter() |
| 1440 | .zip(right) |
| 1441 | .map(|(l, r)| cmp(dst_ty.lane_type(), code, &l, &r)) |
| 1442 | .collect::<ValueResult<SimdVec<DataValue>>>()?; |
| 1443 | |
| 1444 | Ok(vectorizelanes(&res, dst_ty)?) |
| 1445 | } |
| 1446 | |
| 1447 | /// Compare two values using the given floating point condition `code`. |
| 1448 | fn fcmp(code: FloatCC, left: &DataValue, right: &DataValue) -> ValueResult<bool> { |
no test coverage detected