Repository navigation
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
2bb83cf to
33503c2
Compare
|
@rustbot author |
Co-authored-by: Folkert de Vries <folkert@folkertdev.nl>
51f2c2e to
49ec655
Compare
|
@rustbot ready oops sorry ! done |
|
LGTM, thanks! @bors r+ |
…uwer Rollup of 5 pull requests Successful merges: - #162395 (Make more float intrinsics generic) - #164636 (Remove `record_*` macros from the metadata encoder) - #164624 (make `RustaceansAreAwesome` satisfy projection clauses) - #164695 ([tiny] Include trait definition line when pointing at assoc function in E0308) - #164744 (some `Attribute`/`AttributeExt` cleanups)
Rollup merge of #162395 - N1ark:more-float-generics, r=folkertdev Make more float intrinsics generic 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 #150961, cc @RalfJung @tgross35) - `sqrt`, with libm fallbacks - `powf`, with libm fallbacks - `fma` and `fmuladd`, 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](#160989 (comment)). 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`, `maximum` will be handled separately as they require `rustc_allow_const_fn_unstable`: #162414
…uwer Rollup of 5 pull requests Successful merges: - rust-lang/rust#162395 (Make more float intrinsics generic) - rust-lang/rust#164636 (Remove `record_*` macros from the metadata encoder) - rust-lang/rust#164624 (make `RustaceansAreAwesome` satisfy projection clauses) - rust-lang/rust#164695 ([tiny] Include trait definition line when pointing at assoc function in E0308) - rust-lang/rust#164744 (some `Attribute`/`AttributeExt` cleanups)
…uwer Rollup of 5 pull requests Successful merges: - rust-lang/rust#162395 (Make more float intrinsics generic) - rust-lang/rust#164636 (Remove `record_*` macros from the metadata encoder) - rust-lang/rust#164624 (make `RustaceansAreAwesome` satisfy projection clauses) - rust-lang/rust#164695 ([tiny] Include trait definition line when pointing at assoc function in E0308) - rust-lang/rust#164744 (some `Attribute`/`AttributeExt` cleanups)
…uwer Rollup of 5 pull requests Successful merges: - rust-lang/rust#162395 (Make more float intrinsics generic) - rust-lang/rust#164636 (Remove `record_*` macros from the metadata encoder) - rust-lang/rust#164624 (make `RustaceansAreAwesome` satisfy projection clauses) - rust-lang/rust#164695 ([tiny] Include trait definition line when pointing at assoc function in E0308) - rust-lang/rust#164744 (some `Attribute`/`AttributeExt` cleanups)
…uwer Rollup of 5 pull requests Successful merges: - rust-lang/rust#162395 (Make more float intrinsics generic) - rust-lang/rust#164636 (Remove `record_*` macros from the metadata encoder) - rust-lang/rust#164624 (make `RustaceansAreAwesome` satisfy projection clauses) - rust-lang/rust#164695 ([tiny] Include trait definition line when pointing at assoc function in E0308) - rust-lang/rust#164744 (some `Attribute`/`AttributeExt` cleanups)
|
Note that this seems to have caused a regression in cranelift rust-lang/rustc_codegen_cranelift#1717. I think we should be prepared to revert unless there's an easy fix. |
| @@ -39,7 +67,7 @@ macro_rules! intrinsic_dispatch_on_type { | |||
| } | |||
There was a problem hiding this comment.
This fn dispatch doesn't have #[inline] while the other instance does, perhaps that's related?
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