This commit is contained in:
nora 2023-12-03 18:12:31 +01:00
parent 5c1a089038
commit fa39b5faf4
11 changed files with 18 additions and 18 deletions

View file

@ -20,7 +20,7 @@ pub unsafe fn part2(input: &str) -> u64 {
// this out of bounds read is UB under SB, but fine under models that don't do provenance narrowing with slices. i dont care enough to fix it.
let block = bytes.as_ptr().add(i).cast::<u64>().read_unaligned().to_le();
let one = (block & ((1 << (8 * 1)) - 1)) as u8;
let one = (block & ((1 << (8)) - 1)) as u8;
let three = block & ((1 << (8 * 3)) - 1);
let four = block & ((1 << (8 * 4)) - 1);
let five = block & ((1 << (8 * 5)) - 1);
@ -42,7 +42,7 @@ pub unsafe fn part2(input: &str) -> u64 {
};
}
insert(if one >= b'0' && one <= b'9' { one } else { 0 });
insert(if one.is_ascii_digit() { one } else { 0 });
check!(EIGHT five == b"eight" => b'8');
check!(SEVEN five == b"seven" => b'7');

View file

@ -21,7 +21,7 @@ pub unsafe fn part2(input: &str) -> u64 {
.read_unaligned()
.to_le();
let one = (block & ((1 << (8 * 1)) - 1)) as u8;
let one = (block & ((1 << 8) - 1)) as u8;
let three = block & ((1 << (8 * 3)) - 1);
let four = block & ((1 << (8 * 4)) - 1);
let five = block & ((1 << (8 * 5)) - 1);
@ -63,7 +63,7 @@ pub unsafe fn part2(input: &str) -> u64 {
};
}
acc |= if one >= b'0' && one <= b'9' { one } else { 0 };
acc |= if one.is_ascii_digit() { one } else { 0 };
check!(EIGHT five == b"eight" => b'8');
check!(SEVEN five == b"seven" => b'7');

View file

@ -26,7 +26,7 @@ pub unsafe fn part2(input: &str) -> u64 {
.read_unaligned()
.to_le();
let one = (block & ((1 << (8 * 1)) - 1)) as u8;
let one = (block & ((1 << 8) - 1)) as u8;
let three = block & ((1 << (8 * 3)) - 1);
let four = block & ((1 << (8 * 4)) - 1);
let five = block & ((1 << (8 * 5)) - 1);
@ -61,13 +61,14 @@ pub unsafe fn part2(input: &str) -> u64 {
let mut acc = 0;
acc |= if one >= b'0' && one <= b'9' { one } else { 0 };
acc |= if one.is_ascii_digit() { one } else { 0 };
let mut vector_result = None;
#[cfg(all(target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
if avx2 {
use std::arch::x86_64;
#[allow(clippy::let_and_return)]
unsafe fn round(input: u64, compare: [u64; 4], then: [u64; 4]) -> x86_64::__m256i {
// YYYYYYYY|AAAAAAAA|XXXXXXXX|BBBBBBBB|
let compare = unsafe { std::mem::transmute::<_, x86_64::__m256i>(compare) };