-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Added codegen tests for different forms of Option::or
#150564
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: main
Are you sure you want to change the base?
Conversation
|
|
|
rustbot has assigned @Mark-Simulacrum. Use |
1612a70 to
80acf74
Compare
|
r? scottmcm |
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.
Thanks for picking up this work!
Looking mostly good; I left some comments. The DAG one I do feel reasonably strongly about. The others think about and feel free to push back if you think otherwise.
|
Reminder, once the PR becomes ready for a review, use |
…8` and `[u8; 1]` cases Co-authored-by: scottmcm <[email protected]>
…t tests with `NonZero<u8>` input
Thank you very much for the valuable feedback - I agree with all the comments, and have attempted to address and implement all of it. I have two further questions:
Thanks again! |
|
@rustbot ready |
|
| pub fn or_match_nz_u8(opta: Option<NonZero<u8>>, optb: Option<NonZero<u8>>) -> Option<NonZero<u8>> { | ||
| // CHECK: start: | ||
| // CHECK-NEXT: [[NOT_A:%.*]] = icmp eq i8 %0, 0 | ||
| // CHECK-NEXT: select i1 [[NOT_A]], i8 %optb, i8 %0 | ||
| // ret i8 |
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.
Thanks for adding these! Nice to see the argument names and such too, since it's short so that's not a big deal.
But that ret on its own isn't actually checking anything. How about, instead,
| pub fn or_match_nz_u8(opta: Option<NonZero<u8>>, optb: Option<NonZero<u8>>) -> Option<NonZero<u8>> { | |
| // CHECK: start: | |
| // CHECK-NEXT: [[NOT_A:%.*]] = icmp eq i8 %0, 0 | |
| // CHECK-NEXT: select i1 [[NOT_A]], i8 %optb, i8 %0 | |
| // ret i8 | |
| pub fn or_match_nz_u8(opta: Option<NonZero<u8>>, optb: Option<NonZero<u8>>) -> Option<NonZero<u8>> { | |
| // CHECK: start: | |
| // CHECK: [[NOT_A:%.+]] = icmp eq i8 %0, 0 | |
| // CHECK: [[R:%.+]] = select i1 [[NOT_A]], i8 %optb, i8 %0 | |
| // CHECK: ret i8 [[R]] |
Since naming the values means that we're not concerned about other things showing up in the middle, and thus don't need to use the -NEXT that the ones looking at just the instructions do.
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.
(And of course ditto the others below)
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.
Another round of suggestions 🙃
The most important one is about the un-CHECKed ret comments, but ponder the others as well.
Thanks for making the previous updates! Hopefully these are the last things I'll think of.
…ormation in `CHECK-` directives Co-authored-by: scottmcm <[email protected]>
…ith directive contents
|
@rustbot ready Thank you very much again for feedback (and patience!). I've implemented all the suggestions (specifically ensuring all |
Adds tests to check the output of the different ways of writing
Option::orFixes #124533