-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
std: use ptr.offset where possible in the vec iterator. #8225
Conversation
r? @thestinger |
\o/ |
Closes #8212. Before: ```llvm %sum.028 = phi i64 [ %23, %match_else ], [ 0, %"normal return" ] %.sroa.0.027 = phi i64* [ %21, %match_else ], [ %12, %"normal return" ] %19 = ptrtoint i64* %.sroa.0.027 to i64 %20 = add i64 %19, 8 %21 = inttoptr i64 %20 to i64* %22 = load i64* %.sroa.0.027, align 8 %23 = add i64 %22, %sum.028 %24 = inttoptr i64 %20 to %"enum.std::libc::types::common::c95::c_void[#1]"* %25 = icmp eq %"enum.std::libc::types::common::c95::c_void[#1]"* %24, %16 %26 = icmp eq i64 %20, 0 %or.cond = or i1 %25, %26 ``` ``` test vec::bench::iterator ... bench: 87 ns/iter (+/- 7) test vec::bench::mut_iterator ... bench: 87 ns/iter (+/- 10) ``` After: ```llvm %sum.028 = phi i64 [ %21, %match_else ], [ 0, %"normal return" ] %.sroa.0.027 = phi i64* [ %19, %match_else ], [ %12, %"normal return" ] %19 = getelementptr i64* %.sroa.0.027, i64 1 %20 = load i64* %.sroa.0.027, align 8 %21 = add i64 %20, %sum.028 %22 = bitcast i64* %19 to %"enum.std::libc::types::common::c95::c_void[#1]"* %23 = icmp eq %"enum.std::libc::types::common::c95::c_void[#1]"* %22, %16 %24 = icmp eq i64* %19, null %or.cond = or i1 %23, %24 ``` ``` test vec::bench::iterator ... bench: 79 ns/iter (+/- 8) test vec::bench::mut_iterator ... bench: 78 ns/iter (+/- 2) ``` (NB. I'm not 100% sure the benchmarks were set-up correctly, so take them with a grain of salt.)
@huonw: it's fine if the benchmark doesn't show a statistically significant improvement, because I didn't expect any improvement in iteration speed alone - just when combined with other things (it can now optimize iterators to a memset/memcpy with loop-idiom, vectorize them with loop-vectorize and so on). |
@thestinger yes, it was just a warning to anyone that this shouldn't be trumpeted as a 10% speed-up without further investigation. |
Landing with #8257. |
…5, r=giraffate fix `iter_not_returning_iterator` fixes rust-lang#8225 changelog: Handle type projections in `iter_not_returning_iterator` changelog: Don't lint `iter_not_returning_iterator` in trait implementations changelog: Lint `iter_not_returning_iterator` in trait definitions
…agnostic, r=Veykril feat: Add incorrect case diagnostics for traits and their associated items Updates incorrect case diagnostic to: - Check traits and their associated items - Ignore trait implementations except for patterns in associated function bodies Also cleans up `hir-ty::diagnostics::decl_check` a bit (mostly to make it a bit more DRY and easier to maintain) Also fixes: rust-lang#8675 and fixes: rust-lang#8225
Closes #8212.
Before:
After:
(NB. I'm not 100% sure the benchmarks were set-up correctly, so take them with a grain of salt.)