-
Notifications
You must be signed in to change notification settings - Fork 118
Improve codegen for mixing in length #112
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
Improve codegen for mixing in length #112
Conversation
src/operations.rs
Outdated
@@ -146,6 +146,31 @@ pub(crate) fn aesdec(value: u128, xor: u128) -> u128 { | |||
} | |||
} | |||
|
|||
#[inline(always)] | |||
pub(crate) fn add_in_length(enc: &mut u128, len: u64) { | |||
#[cfg(all(target_feature = "sse2", not(miri)))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/operations.rs
Outdated
use core::arch::x86_64::*; | ||
|
||
unsafe { | ||
let enc = std::ptr::addr_of_mut!(*enc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't assume std here.
|
||
unsafe { | ||
let enc = std::ptr::addr_of_mut!(*enc); | ||
let len = _mm_cvtsi64_si128(len as i64); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this 64 bit only? It is giving a compile error on i686.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, 64-bit. I've added target_arch to the cfg on this branch.
f0c91a6
to
7f1ca8f
Compare
7f1ca8f
to
8594bd7
Compare
@tkaitchuck Thanks for the review, I've just pushed updated diff with the fixes. |
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.