Skip to content
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

Replace f16 and f128 pattern matching stubs with real implementations #123088

Merged
merged 2 commits into from
Jun 23, 2024

Conversation

tgross35
Copy link
Contributor

This section of code depends on rustc_apfloat rather than our internal types, so this is one potential ICE that we should be able to melt now.

r? @Nadrieril

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 26, 2024
@rustbot
Copy link
Collaborator

rustbot commented Mar 26, 2024

Some changes occurred in exhaustiveness checking

cc @Nadrieril

@tgross35
Copy link
Contributor Author

Happy to add a test here if you can point me in the right direction, even though what we can actually test is probably pretty limited at this point.

@rustbot label +F-f16_and_f128

@rustbot rustbot added the F-f16_and_f128 `#![feature(f16)]`, `#![feature(f128)]` label Mar 26, 2024
@rust-log-analyzer

This comment has been minimized.

@Nadrieril
Copy link
Member

👍 r=me when CI passes

@tgross35
Copy link
Contributor Author

Whoops I forgot to do the other half of that enum, thanks for the quick look

@Nadrieril
Copy link
Member

Ah yeah, if you have enough implemented a small test would be nice. For example checking that a match expression with two identical -2.0..2.0 patterns lints the second one as unreachable

@tgross35
Copy link
Contributor Author

tgross35 commented Mar 26, 2024

Sure, I can do that. Is there any home for pattern matching tests? Nothing in tests/ui jumps out to me

Edit: oh of course, tests/ui/match

@tgross35
Copy link
Contributor Author

Looks like I am unfortunately jumping the gun here, can't add a reasonable test until I get some more support in core such as #122470, which has its own blockers.

I'll just leave this be until then

@rustbot blocked

@rustbot rustbot added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 26, 2024
@rust-log-analyzer

This comment has been minimized.

@Nadrieril
Copy link
Member

The home for exhaustiveness tests is tests/ui/pattern/usefulness, there's already a file that tests float patterns somewhere there probably

@Nadrieril
Copy link
Member

Nadrieril commented Mar 26, 2024

What you're testing with the tests you added is the execution of matches, i.e. match MIR lowering and codegen. The code you modify in this PR is match checking which is about exhaustiveness and the "unreachable pattern" lint

@Nadrieril
Copy link
Member

ping me again when this is unblocked so I can have a final look

@tgross35
Copy link
Contributor Author

Sounds good, I'll probably just wait for #122470 to land. Thanks for the help!

@bors
Copy link
Contributor

bors commented Mar 31, 2024

☔ The latest upstream changes (presumably #123264) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot
Copy link
Collaborator

rustbot commented Jun 21, 2024

Some changes occurred in match checking

cc @Nadrieril

@rust-log-analyzer

This comment has been minimized.

@tgross35
Copy link
Contributor Author

tgross35 commented Jun 21, 2024

@Nadrieril I think this is ready for a look now, basic library support got merged so that is no longer blocking anything. There are a handful of FIXMEs still because we don't have the INFINITY constants (coming in #126608), but I don't think any of those are load bearing.

For tests I just updated everything that contains a f64 and seems relevant.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Jun 21, 2024
@rust-log-analyzer

This comment has been minimized.

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 22, 2024
fn check_f16() {
const F1: f16 = 0.0;
const F2: f16 = -0.0;
assert_eq!(F1, F2);
Copy link
Member

@Nadrieril Nadrieril Jun 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test failed here. Assuming you ran the tests on your machine, is this platform-specific behavior? Sounds like a nightmare

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said, this is unrelated to this PR since this PR only deals with exhaustiveness checking of floats. You could comment these tests out and fix that in a different PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be failing due to #123885, which will be fixed once compiler-builtins is updated (see #125016).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah if these are hitting any runtime tests then there will be problems on some platforms, I thought everything was going through const eval. I’ll cfg the relevant parts out when I’m back at a computer.

// FIXME(f16_f128): enable infinity tests when constants are available
// assert!(yes!(f16::NEG_INFINITY, ..=f16::NEG_INFINITY));
// assert!(yes!(f16::NEG_INFINITY, ..=1.0f16));
assert!(yes!(1.5f16, ..=1.5f16));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a failure here

@Nadrieril Nadrieril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 22, 2024
@tgross35
Copy link
Contributor Author

@Nadrieril I gated the f16 and f128 tests to only run on aarch64 Linux like I have for #126608, which is the most common platform without ABI issues or missing f128 symbols. As beetrees says, at least the x86 issues with f16 should be fixed when compiler_builtins gets bumped, the others will probably take longer.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 23, 2024
@@ -1,4 +1,6 @@
#![deny(unreachable_patterns)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These will get executed as well. You can make the whole test //@ check-pass

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch, changed

@rust-log-analyzer

This comment has been minimized.

@Nadrieril
Copy link
Member

Oops I got entirely confused: that file was meant to give compile errors x) Please remove the check-pass I suggested

…ions

This section of code depends on `rustc_apfloat` rather than our internal
types, so this is one potential ICE that we should be able to melt now.

This also fixes some missing range and match handling in `rustc_middle`.
@tgross35
Copy link
Contributor Author

It fooled me too, I put it back

@Nadrieril
Copy link
Member

Let's try again!

@bors r+

@bors
Copy link
Contributor

bors commented Jun 23, 2024

📌 Commit 28ce7cd has been approved by Nadrieril

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 23, 2024
@bors
Copy link
Contributor

bors commented Jun 23, 2024

⌛ Testing commit 28ce7cd with merge aabbf84...

@bors
Copy link
Contributor

bors commented Jun 23, 2024

☀️ Test successful - checks-actions
Approved by: Nadrieril
Pushing aabbf84 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 23, 2024
@bors bors merged commit aabbf84 into rust-lang:master Jun 23, 2024
7 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jun 23, 2024
@tgross35
Copy link
Contributor Author

Hey, it worked 🎉 thanks for the review!

@tgross35 tgross35 deleted the f16-f128-pattern-analysis branch June 23, 2024 17:21
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (aabbf84): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.3% [0.3%, 0.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.3%, 0.3%] 1

Max RSS (memory usage)

Results (secondary 5.0%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
5.0% [5.0%, 5.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (secondary -2.5%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.5% [-2.9%, -2.1%] 8
All ❌✅ (primary) - - 0

Binary size

Results (secondary -0.0%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.0% [-0.0%, -0.0%] 1
All ❌✅ (primary) - - 0

Bootstrap: 693.516s -> 691.47s (-0.30%)
Artifact size: 326.77 MiB -> 326.79 MiB (0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-f16_and_f128 `#![feature(f16)]`, `#![feature(f128)]` merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants