Improve codegen for mixing in length#112
Merged
tkaitchuck merged 1 commit intotkaitchuck:masterfrom Feb 27, 2022
Merged
Conversation
tkaitchuck
reviewed
Feb 26, 2022
|
|
||
| #[inline(always)] | ||
| pub(crate) fn add_in_length(enc: &mut u128, len: u64) { | ||
| #[cfg(all(target_feature = "sse2", not(miri)))] |
Owner
There was a problem hiding this comment.
This refers to sse2 and below it refers to sss3, but it looks like these were both meant to be the same so as to provide two alternative paths.
tkaitchuck
reviewed
Feb 26, 2022
| use core::arch::x86_64::*; | ||
|
|
||
| unsafe { | ||
| let enc = std::ptr::addr_of_mut!(*enc); |
|
|
||
| unsafe { | ||
| let enc = std::ptr::addr_of_mut!(*enc); | ||
| let len = _mm_cvtsi64_si128(len as i64); |
Owner
There was a problem hiding this comment.
Is this 64 bit only? It is giving a compile error on i686.
Contributor
Author
There was a problem hiding this comment.
Yep, 64-bit. I've added target_arch to the cfg on this branch.
f0c91a6 to
7f1ca8f
Compare
7f1ca8f to
8594bd7
Compare
Contributor
Author
|
@tkaitchuck Thanks for the review, I've just pushed updated diff with the fixes. |
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.
Minor detail, but produces +17% speed improvement for small strings/byte slices (x86-64).
Measured on Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (Skylake).
Before (relevant part):
In order to add the length it extracts enc[0] into general-purpose register, adds there and then moves it back to vector register (and uses blend).
After:
LLVM able to recognize there is no need to go through GRP and blend.