-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add f16
formatting and parsing
#127013
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
base: master
Are you sure you want to change the base?
Add f16
formatting and parsing
#127013
Conversation
This comment has been minimized.
This comment has been minimized.
@rustbot label +rla-silenced |
@rustbot label +F-f16_and_f128 |
This will need #127510 |
☔ The latest upstream changes (presumably #127020) made this pull request unmergeable. Please resolve the merge conflicts. |
7c3f9c1
to
f3ebeb3
Compare
Update: I'm really just waiting on #128083 to bump stage0, managing |
☔ The latest upstream changes (presumably #128360) made this pull request unmergeable. Please resolve the merge conflicts. |
2eaa479
to
422c52e
Compare
21ffabc
to
2098f01
Compare
404089f
to
3636530
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Add `f16` formatting and parsing Use the same algorithms as for `f32` and `f64` to implement `f16` parsing and printing. try-job: aarch64-gnu
This comment was marked as outdated.
This comment was marked as outdated.
50e6014
to
c5f4a2a
Compare
@bors try |
Add `f16` formatting and parsing Use the same algorithms as for `f32` and `f64` to implement `f16` parsing and printing. try-job: aarch64-gnu
Extend the existing tests for `f32` and `f64` with versions that include `f16`'s new printing and parsing implementations. Co-authored-by: Speedy_Lex <alex.ciocildau@gmail.com>
This requires a fix to the subnormal test to cap the maximum allowed value within the maximum mantissa.
c5f4a2a
to
5b2b504
Compare
@bors try |
Add `f16` formatting and parsing Use the same algorithms as for `f32` and `f64` to implement `f16` parsing and printing. try-job: aarch64-gnu
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
cfaf322
to
e3826ce
Compare
In order to avoid crashes when compiling with Cranelift or on targets where f16 is not well supported, choose to use a fallback based on `target_has_reliable_f16`.
test-float-parse runs with stage0 so it can't use Cc @bjorn3, the fourth patch uses |
@tgross35, what exactly is the problem of using the "is f16 supported" cfg in core/std? Weren't we using a huge target arch selector with a bunch of boolean stuff with x86, aarch64 and neon? Isn't the new cfg cleaner? |
Previously the build.rs config was only used in testing. Bjorn mentioned on Zulip that using it in std that we have to be a bit careful because there are cases where I don't think this is a problem here since the API is the same and the config only determines whether or not a fallback is used, but it's worth somebody double checking my logic. |
Also to be clear this mess unfortunately still exists, it just moved to rust/compiler/rustc_codegen_llvm/src/llvm_util.rs Lines 429 to 494 in 1a95cc6
|
@tgross35, This may be a problem. The cfg does select between implementations but it's selected at compile time as with all cfg's. This means LLVM will remove one of the implementations since it would be dead code. I don't think this is a major problem since f16 hardware impl should be reflected by the target arch. Something like this is what can be used to check and select features at runtime but I think something better would be:
|
Use the same algorithms as for
f32
andf64
to implementf16
parsing and printing.try-job: aarch64-gnu