Skip to content

Commit

Permalink
manually vectorize
Browse files Browse the repository at this point in the history
  • Loading branch information
alion02 committed Dec 18, 2024
1 parent d73aef6 commit dcffa1a
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/day18.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,14 @@ unsafe fn inner1(s: &[u8]) -> u32 {
let mut ptr = s.as_ptr().cast::<i8x16>();
let lut = &LUT;

let map: &mut [u8; 73 * 72 / 8] = &mut array::from_fn(|i| {
if (72 / 8..72 * 72 / 8).contains(&i) {
if i % 9 == 8 {
128
} else {
0
}
} else {
!0
}
});
let map = map.as_mut_ptr();
static mut MAP: [i8; 73 * 72 / 8] = [-1; 73 * 72 / 8];

let map = MAP.as_mut_ptr();
for i in 1..72 {
map.add(i * 72 / 8).cast::<i8x16>().write_unaligned(i8x16::from_array([
0, 0, 0, 0, 0, 0, 0, 0, -128, -1, -1, -1, -1, -1, -1, -1,
]));
}

macro_rules! bts {
($idx:expr) => {
Expand Down

0 comments on commit dcffa1a

Please sign in to comment.