Skip to content

Commit

Permalink
hmm
Browse files Browse the repository at this point in the history
  • Loading branch information
alion02 committed Dec 18, 2024
1 parent 3ef54d1 commit 5513216
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions src/day17.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,31 @@ static LUT: [u64; 1 << 14] = unsafe { transmute(*include_bytes!(concat!(env!("OU

#[inline]
unsafe fn inner2(s: &[u8]) -> u64 {
let s = s.as_ptr().add(59);
let hash = unsafe {
_pext_u64(
s.add(15).cast::<u64>().read_unaligned() ^ s.add(6).read() as u64 ^ (s.add(14).read() as u64 * 65536),
0x07_00_04_00_07_07_04_07,
)
};
*LUT.get_unchecked(hash as usize)
let out: u64;
asm!(
"movzx {out:e}, byte ptr[{ptr} + 73]",
"shl {out:e}, 16",
"xor {out:l}, byte ptr[{ptr} + 65]",
"xor {out}, qword ptr[{ptr} + 74]",
"pext {out}, {out}, {mask}",
"mov {out}, qword ptr[rdx + {out} * 8]",
out = out(reg) out,
out("ecx") _,
inout("rdx") &LUT => _,
ptr = in(reg) s.as_ptr(),
options(nostack),
mask = in(reg) 0x07_00_04_00_07_07_04_07u64,
);
out

// let s = s.as_ptr().add(59);
// let hash = unsafe {
// _pext_u64(
// s.add(15).cast::<u64>().read_unaligned() ^ s.add(6).read() as u64 ^ (s.add(14).read() as u64 * 65536),
// 0x07_00_04_00_07_07_04_07,
// )
// };
// *LUT.get_unchecked(hash as usize)
}

#[inline]
Expand Down

0 comments on commit 5513216

Please sign in to comment.