-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Help LLVM better optimize slice::Iter(Mut)::len #61885
Conversation
This comment has been minimized.
This comment has been minimized.
be3ca63
to
af0e35e
Compare
Nice! r=me unless you want more eyes on this first. |
Yes this looks great! Do we have tests in |
Oh also, should we see if this has any perf influence? |
Well let's get a try build. @bors try |
⌛ Trying commit af0e35e with merge 9dd34620937c9854a002172599a6217be05f6520... |
☀️ Try build successful - checks-travis |
@rust-timer build 9dd34620937c9854a002172599a6217be05f6520 |
Success: Queued 9dd34620937c9854a002172599a6217be05f6520 with parent 6865502, comparison URL. |
Finished benchmarking try commit 9dd34620937c9854a002172599a6217be05f6520, comparison URL. |
Looks like just noise in the perf run, which doesn't surprise me. (Anyone using
Hmm, looks like I get an error[E0080]: Miri evaluation error: unimplemented intrinsic: unchecked_sub on the playground. I guess I should make a MIRI PR before this goes in? Edit: I should have looked, seems like you're already on it rust-lang/miri#776 ❤️ |
I can't find any explicit tests for the slice iterator length method, but running miri-test-libstd on this PR shows that the code path does get hit, e.g. through |
Ah, and this macro also gets used in @bors r=rkruppe,RalfJung |
📌 Commit af0e35e has been approved by |
…ppe,RalfJung Help LLVM better optimize slice::Iter(Mut)::len r? @RalfJung I've included a codegen test that fails without this change as a demonstration of usefulness.
Rollup of 5 pull requests Successful merges: - #61702 (test more variants of enum-int-casting) - #61836 (Replace some uses of NodeId with HirId) - #61885 (Help LLVM better optimize slice::Iter(Mut)::len) - #61893 (make `Weak::ptr_eq`s into methods) - #61908 (don't ICE on large files) Failed merges: r? @ghost
Simplify manual ptr arithmetic in slice::Iter with ptr_sub The old code was introduced in rust-lang#61885, which predates the ptr_sub method and underlying intrinsic. The codegen test still passes. r? `@scottmcm`
r? @RalfJung
I've included a codegen test that fails without this change as a demonstration of usefulness.