Repository navigation
use native interpreter impl for funnel shifts intrinsics #165114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2122,8 +2122,9 @@ pub const unsafe fn unchecked_mul<T: Copy>(x: T, y: T) -> T; | |
| #[rustc_nounwind] | ||
| #[rustc_intrinsic] | ||
| #[rustc_allow_const_fn_unstable(const_trait_impl)] | ||
| #[cfg_attr(miri, track_caller)] | ||
| #[miri::intrinsic_fallback_is_spec] | ||
| pub const fn rotate_left<T: [const] fallback::FunnelShift>(x: T, shift: u32) -> T { | ||
| pub const fn rotate_left<T: fallback::FunnelShift>(x: T, shift: u32) -> T { | ||
| // Make sure to call the intrinsic for `funnel_shl`, not the fallback impl. | ||
| // SAFETY: we modulo `shift` so that the result is definitely less than the size of | ||
| // `T` in bits. | ||
|
|
@@ -2144,8 +2145,9 @@ pub const fn rotate_left<T: [const] fallback::FunnelShift>(x: T, shift: u32) -> | |
| #[rustc_nounwind] | ||
| #[rustc_intrinsic] | ||
| #[rustc_allow_const_fn_unstable(const_trait_impl)] | ||
| #[cfg_attr(miri, track_caller)] | ||
| #[miri::intrinsic_fallback_is_spec] | ||
| pub const fn rotate_right<T: [const] fallback::FunnelShift>(x: T, shift: u32) -> T { | ||
| pub const fn rotate_right<T: fallback::FunnelShift>(x: T, shift: u32) -> T { | ||
| // Make sure to call the intrinsic for `funnel_shr`, not the fallback impl. | ||
| // SAFETY: we modulo `shift` so that the result is definitely less than the size of | ||
| // `T` in bits. | ||
|
|
@@ -2239,17 +2241,11 @@ pub const fn saturating_sub<T: Copy>(a: T, b: T) -> T; | |
| /// | ||
| /// Safe versions of this intrinsic are available on the integer primitives | ||
| /// via the `funnel_shl` method. For example, [`u32::funnel_shl`]. | ||
| #[rustc_intrinsic_const_stable_indirect] | ||
| #[rustc_intrinsic] | ||
| #[rustc_nounwind] | ||
| #[track_caller] | ||
| #[rustc_allow_const_fn_unstable(const_trait_impl, core_intrinsics_fallbacks)] | ||
| #[miri::intrinsic_fallback_is_spec] | ||
| pub const unsafe fn unchecked_funnel_shl<T: [const] fallback::FunnelShift>( | ||
| a: T, | ||
| b: T, | ||
| shift: u32, | ||
| ) -> T { | ||
| #[rustc_intrinsic_const_stable_indirect] | ||
| #[rustc_do_not_const_check] // Use built-in impl to avoid const-checks in the fallback body. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unrelated to this PR: do we ensure nowadays that ctfe doesn't interpret rustc_do_not_const_check bodies?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we have ensured this for >5 years already. See |
||
| pub const unsafe fn unchecked_funnel_shl<T: fallback::FunnelShift>(a: T, b: T, shift: u32) -> T { | ||
| // SAFETY: caller ensures that `shift` is in-range | ||
| unsafe { a.unchecked_funnel_shl(b, shift) } | ||
| } | ||
|
|
@@ -2267,17 +2263,11 @@ pub const unsafe fn unchecked_funnel_shl<T: [const] fallback::FunnelShift>( | |
| /// | ||
| /// Safer versions of this intrinsic are available on the integer primitives | ||
| /// via the `funnel_shr` method. For example, [`u32::funnel_shr`] | ||
| #[rustc_intrinsic_const_stable_indirect] | ||
| #[rustc_intrinsic] | ||
| #[rustc_nounwind] | ||
| #[track_caller] | ||
| #[rustc_allow_const_fn_unstable(const_trait_impl, core_intrinsics_fallbacks)] | ||
| #[miri::intrinsic_fallback_is_spec] | ||
| pub const unsafe fn unchecked_funnel_shr<T: [const] fallback::FunnelShift>( | ||
| a: T, | ||
| b: T, | ||
| shift: u32, | ||
| ) -> T { | ||
| #[rustc_intrinsic_const_stable_indirect] | ||
| #[rustc_do_not_const_check] // Ise built-in impl to avoid const-checks in the fallback body. | ||
| pub const unsafe fn unchecked_funnel_shr<T: fallback::FunnelShift>(a: T, b: T, shift: u32) -> T { | ||
| // SAFETY: caller ensures that `shift` is in-range | ||
| unsafe { a.unchecked_funnel_shr(b, shift) } | ||
| } | ||
|
|
@@ -3489,11 +3479,10 @@ pub const fn maximumf128(x: f128, y: f128) -> f128 { | |
| /// The stabilized versions of this intrinsic are available on the float | ||
| /// primitives via the `abs` method. For example, [`f32::abs`]. | ||
| #[rustc_nounwind] | ||
| #[rustc_const_unstable(feature = "core_intrinsics", issue = "none")] | ||
| #[rustc_intrinsic_const_stable_indirect] | ||
| #[rustc_intrinsic] | ||
| #[rustc_intrinsic_const_stable_indirect] | ||
| #[rustc_do_not_const_check] // Use built-in impl to avoid const-checks in the fallback body. | ||
| #[miri::intrinsic_fallback_is_spec] | ||
| #[rustc_do_not_const_check] // use built-in impl to avoid const-checks in the fallback body. | ||
| pub const fn fabs<T: bounds::FloatPrimitive>(x: T) -> T { | ||
| T::from_bits(x.to_bits() & !T::SIGN_MASK) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes a pre-existing issue for Miri backtraces, making sure they point at where rotate_left is called rather than inside its fallback body.
View changes since the review