-
Notifications
You must be signed in to change notification settings - Fork 13.3k
match lowering: sort Eq
candidates in the failure case too
#122459
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
Conversation
rustbot has assigned @petrochenkov. Use r? to explicitly pick a reviewer |
} else { | ||
fully_matched = false; | ||
Some(TestBranch::Failure) | ||
} |
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.
fully_matched = test_val == case_val;
Some(if fully_matched { TestBranch::Success } else { TestBranch::Failure })
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.
I prefer keeping them separate because the fully_matched logic is already not easy to follow across the function
Is there anybody who reviews pattern matching changes regularly? |
I know one but I was hoping I could give the easy changes to others. Let's see... r? @oli-obk do you follow the match lowering logic? |
@@ -0,0 +1,32 @@ | |||
// skip-filecheck |
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.
Since you're looking for specific patterns, it may be good to use filecheck to ensure it doesn't get blessed away in some larger change
☀️ Test successful - checks-actions |
Finished benchmarking commit (5baf1e1): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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.
Binary sizeResultsThis 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.
Bootstrap: 667.618s -> 670.332s (0.41%) |
This is a slight tweak to MIR gen of matches. Take a match like:
If we switch on
s == "a"
, the first candidate matches, and we learn almost nothing about the second candidate. So there's a choice:flag == true
next.Today, we aren't clever in which tests we pick, so this is an unambiguous win. In a future where we pick tests better, idk. Grouping tests as much as possible feels like a generally good strategy.
This was proposed in #29623 (9 years ago :D)