Reuse the mem::swap optimizations to speed up slice::rotate#42819
Merged
bors merged 1 commit intorust-lang:masterfrom Jun 28, 2017
Merged
Reuse the mem::swap optimizations to speed up slice::rotate#42819bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
Exposes the swapping logic from PR 40454 as `pub unsafe fn ptr::swap_nonoverlapping` under feature swap_nonoverlapping This is most helpful for compound types where LLVM didn't vectorize the loop. Highlight: bench slice::rotate_medium_by727_strings gets 38% faster.
Contributor
|
r? @sfackler (rust_highfive has picked a reviewer for you, use r? to override) |
Member
|
friendly ping @sfackler, pinging you on IRC too! |
Member
|
@bors r+ |
Collaborator
|
📌 Commit 47fa016 has been approved by |
Collaborator
|
⌛ Testing commit 47fa016 with merge 240dcc4d98ed5e20f3d3177ac77debc65aa131e9... |
Collaborator
|
💔 Test failed - status-travis |
Member
|
@bors: retry
|
Collaborator
bors
added a commit
that referenced
this pull request
Jun 28, 2017
Reuse the mem::swap optimizations to speed up slice::rotate This is most helpful for compound types where LLVM didn't vectorize the loop. Highlight: bench slice::rotate_medium_by727_strings gets 38% faster. Exposes the swapping logic from PR #40454 as `pub unsafe fn ptr::swap_nonoverlapping` under library feature `swap_nonoverlapping` #42818. (The new method seemed plausible, and was the simplest way to share the logic. I'm not attached to it, though, so let me know if a different way would be better.)
Collaborator
|
☀️ Test successful - status-appveyor, status-travis |
SimonSapin
reviewed
Jul 5, 2017
| pub unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) { | ||
| let x = x as *mut u8; | ||
| let y = y as *mut u8; | ||
| let len = mem::size_of::<T>() * count; |
Contributor
There was a problem hiding this comment.
Should this use .checked_mul(count).unwrap()?
Member
Author
There was a problem hiding this comment.
I don't think that's necessary, because of the safety requirement that the arguments refer to valid ranges of memory -- if it's valid, its length must fit in a usize.
cuviper
added a commit
to cuviper/rust
that referenced
this pull request
Jul 11, 2017
This is a workaround for rust-lang#42778, which was git-bisected to rust-lang#40454's optimizations to `mem::swap`, later moved to `ptr` in rust-lang#42819. Natively compiled rustc couldn't even compile stage1 libcore on powerpc64 and s390x, but they work fine without this `repr(simd)`. Since powerpc64le works OK, it seems probably related to being big-endian. The underlying problem is not yet known, but this at least makes those architectures functional again in the meantime. cc @arielb1
frewsxcv
added a commit
to frewsxcv/rust
that referenced
this pull request
Jul 15, 2017
Disable big-endian simd in swap_nonoverlapping_bytes This is a workaround for rust-lang#42778, which was git-bisected to rust-lang#40454's optimizations to `mem::swap`, later moved to `ptr` in rust-lang#42819. Natively compiled rustc couldn't even compile stage1 libcore on powerpc64 and s390x, but they work fine without this `repr(simd)`. Since powerpc64le works OK, it seems probably related to being big-endian. The underlying problem is not yet known, but this at least makes those architectures functional again in the meantime. cc @arielb1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is most helpful for compound types where LLVM didn't vectorize the loop. Highlight: bench slice::rotate_medium_by727_strings gets 38% faster.
Exposes the swapping logic from PR #40454 as
pub unsafe fn ptr::swap_nonoverlappingunder library featureswap_nonoverlapping#42818.(The new method seemed plausible, and was the simplest way to share the logic. I'm not attached to it, though, so let me know if a different way would be better.)