Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

huonw
Copy link
Member

@huonw huonw commented Aug 2, 2013

Closes #8212.

Before:

%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:

%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
Copy link
Member Author

huonw commented Aug 2, 2013

r? @thestinger

@thestinger
Copy link
Contributor

\o/

bors added a commit that referenced this pull request Aug 2, 2013
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.)
@thestinger
Copy link
Contributor

@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).

@huonw
Copy link
Member Author

huonw commented Aug 3, 2013

@thestinger yes, it was just a warning to anyone that this shouldn't be trumpeted as a 10% speed-up without further investigation.

@thestinger
Copy link
Contributor

Landing with #8257.

@thestinger thestinger closed this Aug 3, 2013
@huonw huonw deleted the vec-iter branch December 4, 2014 02:02
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jan 13, 2022
…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
matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this pull request Feb 11, 2024
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make the vector iterator use GEP, not ptrtoint + add + inttoptr
2 participants