Make more float intrinsics generic - #162395
Conversation
|
Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri
cc @rust-lang/miri
cc @tgross35 Some changes occurred to the CTFE machinery
cc @Amanieu, @folkertdev, @sayantn Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr
cc @rust-lang/miri Any special-casing of Miri in the standard library requires review. cc @rust-lang/miri
cc @bjorn3
cc @rust-lang/wg-const-eval |
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
| #[rustc_const_unstable(feature = "core_intrinsics", issue = "none")] | ||
| #[rustc_intrinsic_const_stable_indirect] |
There was a problem hiding this comment.
Noted this required adding #[rustc_const_unstable] to the whole intrinsic,
Why was this needed? I guess it is because the body now needs unstable const features, namely const traits? We should ensure const traits are stable enough before we do that.
(I now notice that you already did the same for fabs. We should have already checked this there then but forgot.)
@BoxyUwU @lcnr @oli-obk are const traits in a state where we can use them internally in const functions that can be called by public monomorphic stable const functions? I think this still allows us to change the syntax and logic for const traits pretty much arbitrarily as long as we keep some way of invoking trait functions in a const fn.
There was a problem hiding this comment.
cc @fee1-dead
This is not the only case of such usage. Equivalent behaviour is here to stay and syntactical changes don't cause bootstrap churn anymore, so to me personally it is fine to add more, especially for intrinsic bodies which can always be replaced by an actual impl again
d78924b to
06625b8
Compare
|
cc @rust-lang/clippy |
06625b8 to
da4599d
Compare
This comment has been minimized.
This comment has been minimized.
ca3f9a9 to
b4275be
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment has been minimized.
This comment has been minimized.
b4275be to
49057d4
Compare
|
Please also update the PR description to reflect which intrinsics are actually being changed here now. |
This comment has been minimized.
This comment has been minimized.
| where | ||
| F: rustc_apfloat::Float + rustc_apfloat::FloatConvert<F> + Into<Scalar<M::Provenance>>, | ||
| { | ||
| let x: F = x.to_float()?; |
There was a problem hiding this comment.
By removing this here, now every caller needs to call to_float first... is that really better?
There was a problem hiding this comment.
i found it nicer, because it means outside of SIMD we only do the x: F = x.to_float()? thing in one place, avoiding additional wrappers or calls elsewhere. it does make the SIMD intrinsics slightly bigger but i think it's nicer for the more general case
49057d4 to
2bb83cf
Compare
2bb83cf to
33503c2
Compare
b6e3544 to
8d81bf9
Compare
|
@rustbot reroll |
|
r? @tgross35 |
|
|
| let arg = AbiParam::new(ty); | ||
| fx.lib_call(name, vec![arg, arg], vec![arg], &[x, y])[0] | ||
| } | ||
| }; |
There was a problem hiding this comment.
The codegen variant is never used here.
View all comments
Another (big) step of #153834 + #160989
Makemore remaining float intrinsics generic! Each commit is self-contained.
In order:
ceil,floor,trunc,round,round_ties_even, with const libm fallbacks (using#[rustc_do_not_const_check], see Intrinsics should allow a non-const fallback body if hooked for CTFE #150961, cc @RalfJung @tgross35)sqrt, with libm fallbackspowf, with libm fallbacksfmaandfmuladd, with libm fallbacks (+#[rustc_do_not_const_check]) and a shared fallback, respectively.powi, with no fallback (it already didn't have any)The first commit just removes the f16/f128 fallbacks for
fabs, as mentioned here. I didn't try making the backends use more fallbacks, to make the PR less risky since it's quite large. Happy to do changes there though (cc @folkertdev)copysign,minimum_number_nsz,maximum_number_nsz,minimum,maximumwill be handled separately as they requirerustc_allow_const_fn_unstable: #162414