Skip to content

Commit

Permalink
Inline 8x16 compression
Browse files Browse the repository at this point in the history
  • Loading branch information
ogxd committed Nov 17, 2024
1 parent 9342750 commit 1fffefb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
13 changes: 7 additions & 6 deletions src/gxhash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ macro_rules! load_unaligned {

pub(crate) use load_unaligned;

#[cfg(target_arch = "arm")]
use core::arch::arm::*;
#[cfg(target_arch = "aarch64")]
use core::arch::aarch64::*;

#[inline(always)]
pub(crate) unsafe fn gxhash(input: &[u8], seed: State) -> State {
return finalize(gxhash_no_finish(input, seed));
Expand All @@ -94,7 +89,13 @@ pub(crate) unsafe fn gxhash_no_finish(input: &[u8], seed: State) -> State {
if len < 16 {
break 'p1;
} else if len < 128 {
// Possibly we can have something here
// Turbo mode, but is it worth the extra code size?
// It's not even great quality-wise, and v0 mix v1 may be a source of DOS collision attack
// if len >= 32 {
// load_unaligned!(ptr, v0, v1);
// state = aes_encrypt(state, aes_encrypt(v0, v1));
// whole_vector_count -= 2;
// }
break 'p2;
}

Expand Down
2 changes: 1 addition & 1 deletion src/gxhash/platform/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub unsafe fn ld(array: *const u32) -> State {
vreinterpretq_s8_u32(vld1q_u32(array))
}

#[inline(never)]
#[inline(always)]
pub unsafe fn compress_8(mut ptr: *const State, whole_vector_count: usize, hash_vector: State, len: usize) -> (State, *const State, usize) {

let end_address = ptr.add((whole_vector_count / 8) * 8) as usize;
Expand Down
4 changes: 2 additions & 2 deletions src/gxhash/platform/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub unsafe fn ld(array: *const u32) -> State {
}

#[cfg(not(feature = "hybrid"))]
#[inline(never)]
#[inline(always)]
pub unsafe fn compress_8(mut ptr: *const State, whole_vector_count: usize, hash_vector: State, len: usize) -> State {

let end_address = ptr.add((whole_vector_count / 8) * 8) as usize;
Expand Down Expand Up @@ -113,7 +113,7 @@ pub unsafe fn compress_8(mut ptr: *const State, whole_vector_count: usize, hash_
}

#[cfg(feature = "hybrid")]
#[inline(never)]
#[inline(always)]
pub unsafe fn compress_8(ptr: *const State, end_address: usize, hash_vector: State, len: usize) -> State {
macro_rules! load_unaligned_x2 {
($ptr:ident, $($var:ident),+) => {
Expand Down

0 comments on commit 1fffefb

Please sign in to comment.