-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Array .len()
MIR optimization pass
#86525
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @LeSeulArtichaut (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Due to dependency it's better to look at The main pain point is that the only way to deal with an expression like this |
r? @oli-obk |
This comment has been minimized.
This comment has been minimized.
There is an alternative approach to run this pass somewhat later, and assume that after previous passes we are only interested in cases when the destination of cast is only touched in the
Even more alternative approach is to go full scale dataflow analysis and be able to remove a unsize cast by proving that all other potentially dependent statements are ok with |
@bors try All tests passed locally, problem was due to not committed files |
@shamatar: 🔑 Insufficient privileges: not in try users |
I'll add for completeness @rustbot label: +S-waiting-on-review |
For it to work an operand of |
- _8 = Lt(_6, _7); // scope 0 at $DIR/slice_len.rs:5:5: 5:33 | ||
- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 0 at $DIR/slice_len.rs:5:5: 5:33 | ||
+ _7 = const 3_usize; // scope 0 at $DIR/slice_len.rs:5:5: 5:33 | ||
+ _8 = const true; // scope 0 at $DIR/slice_len.rs:5:5: 5:33 | ||
+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> bb1; // scope 0 at $DIR/slice_len.rs:5:5: 5:33 |
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.
Hmm, shouldn't be this assert removed, as it const true? Or maybe in other pass, i don't really understand this thing deep enough.
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.
It may be removed, but the test doesn't output the results of other passes, just the diff due to application of ConstProp
one
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.
We run a SimplifyBranches
pass right after ConstProp
which will turn the assert into goto -> bb1
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 87797843fb2598134ec8ecc86dc718c0d4657a22 with merge d903a20d696dba2fa37a25fe955133069819febc... |
@rustbot label: -S-blocked |
💔 Test failed - checks-actions |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@JohnCSimon Done |
@bors r+ Thanks for bearing with us while we figure out our process for reviewing mir opts with the little review capacity we have in wg-mir-opt. |
📌 Commit a31518f has been approved by |
⌛ Testing commit a31518f with merge 5c402bc869d4e1188ec5974820481d49b1040322... |
💔 Test failed - checks-actions |
Looks like random error during CI execution |
@bors retry |
☀️ Test successful - checks-actions |
☀️ Test successful - checks-actions |
Finished benchmarking commit (680ff86): comparison url. Summary: This benchmark run did not return any relevant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
This pass kind-of works back the
[T; N].len()
call that at the moment is first coerced as&[T; N]
->&[T]
and then uses&[T].len()
. Depends on #86383