From 9a84c005f6720530c73a95aa940f13b99eea33fd Mon Sep 17 00:00:00 2001 From: sayantn Date: Thu, 4 Dec 2025 22:28:54 +0530 Subject: [PATCH] mark const SIMD intrinsics as indirectly stable --- library/core/src/intrinsics/simd.rs | 60 +++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/library/core/src/intrinsics/simd.rs b/library/core/src/intrinsics/simd.rs index 722a765cd01ee..4ed8f66b16321 100644 --- a/library/core/src/intrinsics/simd.rs +++ b/library/core/src/intrinsics/simd.rs @@ -13,6 +13,7 @@ use crate::marker::ConstParamTy; /// `idx` must be in-bounds of the vector. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_insert(x: T, idx: u32, val: U) -> T; /// Extracts an element from a vector. @@ -24,6 +25,7 @@ pub const unsafe fn simd_insert(x: T, idx: u32, val: U) -> T; /// `idx` must be const and in-bounds of the vector. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_extract(x: T, idx: u32) -> U; /// Inserts an element into a vector, returning the updated vector. @@ -64,6 +66,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// `T` must be a vector of integers or floats. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_add(x: T, y: T) -> T; /// Subtracts `rhs` from `lhs` elementwise. @@ -71,6 +74,7 @@ pub const unsafe fn simd_add(x: T, y: T) -> T; /// `T` must be a vector of integers or floats. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_sub(lhs: T, rhs: T) -> T; /// Multiplies two simd vectors elementwise. @@ -78,6 +82,7 @@ pub const unsafe fn simd_sub(lhs: T, rhs: T) -> T; /// `T` must be a vector of integers or floats. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_mul(x: T, y: T) -> T; /// Divides `lhs` by `rhs` elementwise. @@ -89,6 +94,7 @@ pub const unsafe fn simd_mul(x: T, y: T) -> T; /// Additionally for signed integers, `::MIN / -1` is undefined behavior. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_div(lhs: T, rhs: T) -> T; /// Returns remainder of two vectors elementwise. @@ -100,6 +106,7 @@ pub const unsafe fn simd_div(lhs: T, rhs: T) -> T; /// Additionally for signed integers, `::MIN / -1` is undefined behavior. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_rem(lhs: T, rhs: T) -> T; /// Shifts vector left elementwise, with UB on overflow. @@ -113,6 +120,7 @@ pub const unsafe fn simd_rem(lhs: T, rhs: T) -> T; /// Each element of `rhs` must be less than `::BITS`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_shl(lhs: T, rhs: T) -> T; /// Shifts vector right elementwise, with UB on overflow. @@ -126,6 +134,7 @@ pub const unsafe fn simd_shl(lhs: T, rhs: T) -> T; /// Each element of `rhs` must be less than `::BITS`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_shr(lhs: T, rhs: T) -> T; /// Funnel Shifts vector left elementwise, with UB on overflow. @@ -143,6 +152,7 @@ pub const unsafe fn simd_shr(lhs: T, rhs: T) -> T; /// Each element of `shift` must be less than `::BITS`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_funnel_shl(a: T, b: T, shift: T) -> T; /// Funnel Shifts vector right elementwise, with UB on overflow. @@ -160,6 +170,7 @@ pub const unsafe fn simd_funnel_shl(a: T, b: T, shift: T) -> T; /// Each element of `shift` must be less than `::BITS`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_funnel_shr(a: T, b: T, shift: T) -> T; /// "And"s vectors elementwise. @@ -167,6 +178,7 @@ pub const unsafe fn simd_funnel_shr(a: T, b: T, shift: T) -> T; /// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_and(x: T, y: T) -> T; /// "Ors" vectors elementwise. @@ -174,6 +186,7 @@ pub const unsafe fn simd_and(x: T, y: T) -> T; /// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_or(x: T, y: T) -> T; /// "Exclusive ors" vectors elementwise. @@ -181,6 +194,7 @@ pub const unsafe fn simd_or(x: T, y: T) -> T; /// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_xor(x: T, y: T) -> T; /// Numerically casts a vector, elementwise. @@ -202,6 +216,7 @@ pub const unsafe fn simd_xor(x: T, y: T) -> T; /// * Be representable in the return type, after truncating off its fractional part #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_cast(x: T) -> U; /// Numerically casts a vector, elementwise. @@ -216,6 +231,7 @@ pub const unsafe fn simd_cast(x: T) -> U; /// Otherwise, truncates or extends the value, maintaining the sign for signed integers. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_as(x: T) -> U; /// Negates a vector elementwise. @@ -225,6 +241,7 @@ pub const unsafe fn simd_as(x: T) -> U; /// Rust panics for `-::Min` due to overflow, but it is not UB with this intrinsic. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_neg(x: T) -> T; /// Returns absolute value of a vector, elementwise. @@ -232,6 +249,7 @@ pub const unsafe fn simd_neg(x: T) -> T; /// `T` must be a vector of floating-point primitive types. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_fabs(x: T) -> T; /// Returns the minimum of two vectors, elementwise. @@ -241,6 +259,7 @@ pub const unsafe fn simd_fabs(x: T) -> T; /// Follows IEEE-754 `minNum` semantics. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_fmin(x: T, y: T) -> T; /// Returns the maximum of two vectors, elementwise. @@ -250,6 +269,7 @@ pub const unsafe fn simd_fmin(x: T, y: T) -> T; /// Follows IEEE-754 `maxNum` semantics. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_fmax(x: T, y: T) -> T; /// Tests elementwise equality of two vectors. @@ -261,6 +281,7 @@ pub const unsafe fn simd_fmax(x: T, y: T) -> T; /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_eq(x: T, y: T) -> U; /// Tests elementwise inequality equality of two vectors. @@ -272,6 +293,7 @@ pub const unsafe fn simd_eq(x: T, y: T) -> U; /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_ne(x: T, y: T) -> U; /// Tests if `x` is less than `y`, elementwise. @@ -283,6 +305,7 @@ pub const unsafe fn simd_ne(x: T, y: T) -> U; /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_lt(x: T, y: T) -> U; /// Tests if `x` is less than or equal to `y`, elementwise. @@ -294,6 +317,7 @@ pub const unsafe fn simd_lt(x: T, y: T) -> U; /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_le(x: T, y: T) -> U; /// Tests if `x` is greater than `y`, elementwise. @@ -305,6 +329,7 @@ pub const unsafe fn simd_le(x: T, y: T) -> U; /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_gt(x: T, y: T) -> U; /// Tests if `x` is greater than or equal to `y`, elementwise. @@ -316,6 +341,7 @@ pub const unsafe fn simd_gt(x: T, y: T) -> U; /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_ge(x: T, y: T) -> U; /// Shuffles two vectors by const indices. @@ -332,6 +358,7 @@ pub const unsafe fn simd_ge(x: T, y: T) -> U; /// of `xy`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_shuffle(x: T, y: T, idx: U) -> V; /// Reads a vector of pointers. @@ -353,6 +380,7 @@ pub const unsafe fn simd_shuffle(x: T, y: T, idx: U) -> V; /// `mask` must only contain `0` or `!0` values. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_gather(val: T, ptr: U, mask: V) -> T; /// Writes to a vector of pointers. @@ -377,6 +405,7 @@ pub const unsafe fn simd_gather(val: T, ptr: U, mask: V) -> T; /// `mask` must only contain `0` or `!0` values. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_scatter(val: T, ptr: U, mask: V); /// A type for alignment options for SIMD masked load/store intrinsics. @@ -412,6 +441,7 @@ pub enum SimdAlign { /// `mask` must only contain `0` or `!0` values. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_masked_load(mask: V, ptr: U, val: T) -> T; @@ -434,6 +464,7 @@ pub const unsafe fn simd_masked_load(mask: V, p /// `mask` must only contain `0` or `!0` values. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_masked_store(mask: V, ptr: U, val: T); /// Adds two simd vectors elementwise, with saturation. @@ -441,6 +472,7 @@ pub const unsafe fn simd_masked_store(mask: V, /// `T` must be a vector of integer primitive types. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_saturating_add(x: T, y: T) -> T; /// Subtracts two simd vectors elementwise, with saturation. @@ -450,6 +482,7 @@ pub const unsafe fn simd_saturating_add(x: T, y: T) -> T; /// Subtract `rhs` from `lhs`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_saturating_sub(lhs: T, rhs: T) -> T; /// Adds elements within a vector from left to right. @@ -461,6 +494,7 @@ pub const unsafe fn simd_saturating_sub(lhs: T, rhs: T) -> T; /// Starting with the value `y`, add the elements of `x` and accumulate. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_reduce_add_ordered(x: T, y: U) -> U; /// Adds elements within a vector in arbitrary order. May also be re-associated with @@ -482,6 +516,7 @@ pub unsafe fn simd_reduce_add_unordered(x: T) -> U; /// Starting with the value `y`, multiply the elements of `x` and accumulate. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_reduce_mul_ordered(x: T, y: U) -> U; /// Multiplies elements within a vector in arbitrary order. May also be re-associated with @@ -502,6 +537,7 @@ pub unsafe fn simd_reduce_mul_unordered(x: T) -> U; /// `x` must contain only `0` or `!0`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_reduce_all(x: T) -> bool; /// Checks if any mask value is true. @@ -512,6 +548,7 @@ pub const unsafe fn simd_reduce_all(x: T) -> bool; /// `x` must contain only `0` or `!0`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_reduce_any(x: T) -> bool; /// Returns the maximum element of a vector. @@ -523,6 +560,7 @@ pub const unsafe fn simd_reduce_any(x: T) -> bool; /// For floating-point values, uses IEEE-754 `maxNum`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_reduce_max(x: T) -> U; /// Returns the minimum element of a vector. @@ -534,6 +572,7 @@ pub const unsafe fn simd_reduce_max(x: T) -> U; /// For floating-point values, uses IEEE-754 `minNum`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_reduce_min(x: T) -> U; /// Logical "and"s all elements together. @@ -543,6 +582,7 @@ pub const unsafe fn simd_reduce_min(x: T) -> U; /// `U` must be the element type of `T`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_reduce_and(x: T) -> U; /// Logical "ors" all elements together. @@ -552,6 +592,7 @@ pub const unsafe fn simd_reduce_and(x: T) -> U; /// `U` must be the element type of `T`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_reduce_or(x: T) -> U; /// Logical "exclusive ors" all elements together. @@ -561,6 +602,7 @@ pub const unsafe fn simd_reduce_or(x: T) -> U; /// `U` must be the element type of `T`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_reduce_xor(x: T) -> U; /// Truncates an integer vector to a bitmask. @@ -598,6 +640,7 @@ pub const unsafe fn simd_reduce_xor(x: T) -> U; /// `x` must contain only `0` and `!0`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_bitmask(x: T) -> U; /// Selects elements from a mask. @@ -614,6 +657,7 @@ pub const unsafe fn simd_bitmask(x: T) -> U; /// `mask` must only contain `0` and `!0`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_select(mask: M, if_true: T, if_false: T) -> T; /// Selects elements from a bitmask. @@ -630,6 +674,7 @@ pub const unsafe fn simd_select(mask: M, if_true: T, if_false: T) -> T; /// The bitmask bit order matches `simd_bitmask`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_select_bitmask(m: M, yes: T, no: T) -> T; /// Calculates the offset from a pointer vector elementwise, potentially @@ -642,6 +687,7 @@ pub const unsafe fn simd_select_bitmask(m: M, yes: T, no: T) -> T; /// Operates as if by `::wrapping_offset`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_arith_offset(ptr: T, offset: U) -> T; /// Casts a vector of pointers. @@ -649,6 +695,7 @@ pub const unsafe fn simd_arith_offset(ptr: T, offset: U) -> T; /// `T` and `U` must be vectors of pointers with the same number of elements. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_cast_ptr(ptr: T) -> U; /// Exposes a vector of pointers as a vector of addresses. @@ -667,6 +714,7 @@ pub unsafe fn simd_expose_provenance(ptr: T) -> U; /// `U` must be a vector of pointers, with the same length as `T`. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_with_exposed_provenance(addr: T) -> U; /// Swaps bytes of each element. @@ -674,6 +722,7 @@ pub const unsafe fn simd_with_exposed_provenance(addr: T) -> U; /// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_bswap(x: T) -> T; /// Reverses bits of each element. @@ -681,6 +730,7 @@ pub const unsafe fn simd_bswap(x: T) -> T; /// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_bitreverse(x: T) -> T; /// Counts the leading zeros of each element. @@ -688,6 +738,7 @@ pub const unsafe fn simd_bitreverse(x: T) -> T; /// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_ctlz(x: T) -> T; /// Counts the number of ones in each element. @@ -695,6 +746,7 @@ pub const unsafe fn simd_ctlz(x: T) -> T; /// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_ctpop(x: T) -> T; /// Counts the trailing zeros of each element. @@ -702,6 +754,7 @@ pub const unsafe fn simd_ctpop(x: T) -> T; /// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_cttz(x: T) -> T; /// Rounds up each element to the next highest integer-valued float. @@ -709,6 +762,7 @@ pub const unsafe fn simd_cttz(x: T) -> T; /// `T` must be a vector of floats. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_ceil(x: T) -> T; /// Rounds down each element to the next lowest integer-valued float. @@ -716,6 +770,7 @@ pub const unsafe fn simd_ceil(x: T) -> T; /// `T` must be a vector of floats. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_floor(x: T) -> T; /// Rounds each element to the closest integer-valued float. @@ -724,6 +779,7 @@ pub const unsafe fn simd_floor(x: T) -> T; /// `T` must be a vector of floats. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_round(x: T) -> T; /// Rounds each element to the closest integer-valued float. @@ -732,6 +788,7 @@ pub const unsafe fn simd_round(x: T) -> T; /// `T` must be a vector of floats. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_round_ties_even(x: T) -> T; /// Returns the integer part of each element as an integer-valued float. @@ -740,6 +797,7 @@ pub const unsafe fn simd_round_ties_even(x: T) -> T; /// `T` must be a vector of floats. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_trunc(x: T) -> T; /// Takes the square root of each element. @@ -754,6 +812,7 @@ pub unsafe fn simd_fsqrt(x: T) -> T; /// `T` must be a vector of floats. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_fma(x: T, y: T, z: T) -> T; /// Computes `(x*y) + z` for each element, non-deterministically executing either @@ -769,6 +828,7 @@ pub const unsafe fn simd_fma(x: T, y: T, z: T) -> T; /// `T` must be a vector of floats. #[rustc_intrinsic] #[rustc_nounwind] +#[rustc_intrinsic_const_stable_indirect] pub const unsafe fn simd_relaxed_fma(x: T, y: T, z: T) -> T; // Computes the sine of each element.