Skip to content

Commit

Permalink
correct the docs on simd_ comparison operators
Browse files Browse the repository at this point in the history
these all also accept integer vectors as arguments
  • Loading branch information
folkertdev committed Feb 28, 2025
1 parent 96cfc75 commit 4549266
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions library/core/src/intrinsics/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,28 @@ pub unsafe fn simd_extract<T, U>(_x: T, _idx: u32) -> U;

/// Adds two simd vectors elementwise.
///
/// `T` must be a vector of integer or floating point primitive types.
/// `T` must be a vector of integers or floats.
#[rustc_intrinsic]
#[rustc_nounwind]
pub unsafe fn simd_add<T>(_x: T, _y: T) -> T;

/// Subtracts `rhs` from `lhs` elementwise.
///
/// `T` must be a vector of integer or floating point primitive types.
/// `T` must be a vector of integers or floats.
#[rustc_intrinsic]
#[rustc_nounwind]
pub unsafe fn simd_sub<T>(_lhs: T, _rhs: T) -> T;

/// Multiplies two simd vectors elementwise.
///
/// `T` must be a vector of integer or floating point primitive types.
/// `T` must be a vector of integers or floats.
#[rustc_intrinsic]
#[rustc_nounwind]
pub unsafe fn simd_mul<T>(_x: T, _y: T) -> T;

/// Divides `lhs` by `rhs` elementwise.
///
/// `T` must be a vector of integer or floating point primitive types.
/// `T` must be a vector of integers or floats.
///
/// # Safety
/// For integers, `rhs` must not contain any zero elements.
Expand All @@ -58,7 +58,7 @@ pub unsafe fn simd_div<T>(_lhs: T, _rhs: T) -> T;

/// Returns remainder of two vectors elementwise.
///
/// `T` must be a vector of integer or floating point primitive types.
/// `T` must be a vector of integers or floats.
///
/// # Safety
/// For integers, `rhs` must not contain any zero elements.
Expand Down Expand Up @@ -116,8 +116,7 @@ pub unsafe fn simd_xor<T>(_x: T, _y: T) -> T;

/// Numerically casts a vector, elementwise.
///
/// `T` and `U` must be vectors of integer or floating point primitive types, and must have the
/// same length.
/// `T` and `U` must be vectors of integers or floats, and must have the same length.
///
/// When casting floats to integers, the result is truncated. Out-of-bounds result lead to UB.
/// When casting integers to floats, the result is rounded.
Expand All @@ -138,8 +137,7 @@ pub unsafe fn simd_cast<T, U>(_x: T) -> U;

/// Numerically casts a vector, elementwise.
///
/// `T` and `U` be a vectors of integer or floating point primitive types, and must have the
/// same length.
/// `T` and `U` be a vectors of integers or floats, and must have the same length.
///
/// Like `simd_cast`, but saturates float-to-integer conversions (NaN becomes 0).
/// This matches regular `as` and is always safe.
Expand Down Expand Up @@ -187,7 +185,7 @@ pub unsafe fn simd_fmax<T>(_x: T, _y: T) -> T;

/// Tests elementwise equality of two vectors.
///
/// `T` must be a vector of floating-point primitive types.
/// `T` must be a vector of integer or floating-point primitive types.
///
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
///
Expand All @@ -198,7 +196,7 @@ pub unsafe fn simd_eq<T, U>(_x: T, _y: T) -> U;

/// Tests elementwise inequality equality of two vectors.
///
/// `T` must be a vector of floating-point primitive types.
/// `T` must be a vector of integer or floating-point primitive types.
///
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
///
Expand All @@ -209,7 +207,7 @@ pub unsafe fn simd_ne<T, U>(_x: T, _y: T) -> U;

/// Tests if `x` is less than `y`, elementwise.
///
/// `T` must be a vector of floating-point primitive types.
/// `T` must be a vector of integer or floating-point primitive types.
///
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
///
Expand All @@ -220,7 +218,7 @@ pub unsafe fn simd_lt<T, U>(_x: T, _y: T) -> U;

/// Tests if `x` is less than or equal to `y`, elementwise.
///
/// `T` must be a vector of floating-point primitive types.
/// `T` must be a vector of integer or floating-point primitive types.
///
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
///
Expand All @@ -231,7 +229,7 @@ pub unsafe fn simd_le<T, U>(_x: T, _y: T) -> U;

/// Tests if `x` is greater than `y`, elementwise.
///
/// `T` must be a vector of floating-point primitive types.
/// `T` must be a vector of integer or floating-point primitive types.
///
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
///
Expand All @@ -242,7 +240,7 @@ pub unsafe fn simd_gt<T, U>(_x: T, _y: T) -> U;

/// Tests if `x` is greater than or equal to `y`, elementwise.
///
/// `T` must be a vector of floating-point primitive types.
/// `T` must be a vector of integer or floating-point primitive types.
///
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
///
Expand Down

0 comments on commit 4549266

Please sign in to comment.