Skip to content

Commit c82d57f

Browse files
committed
Revert "Auto vectorise?"
This reverts commit 9e03f7f.
1 parent 9e03f7f commit c82d57f

File tree

1 file changed

+16
-42
lines changed

1 file changed

+16
-42
lines changed

src/day13.rs

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use aoc_runner_derive::aoc;
2-
use std::arch::x86_64::*;
32

43
#[aoc(day13, part1)]
54
pub fn part1(s: &str) -> u64 {
@@ -17,63 +16,38 @@ pub fn part2(s: &str) -> u64 {
1716
}
1817
}
1918

20-
#[target_feature(enable = "avx2,bmi1,bmi2,cmpxchg16b,lzcnt,movbe,popcnt")]
21-
unsafe fn inner<const OFFSET: i64>(s: &str) -> u64 {
19+
// #[target_feature(enable = "avx2,bmi1,bmi2,cmpxchg16b,lzcnt,movbe,popcnt")]
20+
fn inner<const OFFSET: i64>(s: &str) -> u64 {
2221
let s = s.as_bytes();
2322

2423
let mut sum = 0;
2524

26-
let mut axs = [0i64; 320];
27-
let mut ays = [0i64; 320];
28-
let mut bxs = [0i64; 320];
29-
let mut bys = [0i64; 320];
30-
let mut xs = [0i64; 320];
31-
let mut ys = [0i64; 320];
32-
33-
let mut p = 0;
3425
let mut i = 0;
35-
while p < s.len() {
36-
let ax = ((s[p + 12] - b'0') * 10 + s[p + 13] - b'0') as i64;
37-
let ay = ((s[p + 18] - b'0') * 10 + s[p + 19] - b'0') as i64;
26+
while i < s.len() {
27+
let ax = ((s[i + 12] - b'0') * 10 + s[i + 13] - b'0') as i64;
28+
let ay = ((s[i + 18] - b'0') * 10 + s[i + 19] - b'0') as i64;
3829

39-
let bx = ((s[p + 33] - b'0') * 10 + s[p + 34] - b'0') as i64;
40-
let by = ((s[p + 39] - b'0') * 10 + s[p + 40] - b'0') as i64;
41-
p += 51;
30+
let bx = ((s[i + 33] - b'0') * 10 + s[i + 34] - b'0') as i64;
31+
let by = ((s[i + 39] - b'0') * 10 + s[i + 40] - b'0') as i64;
32+
i += 51;
4233

4334
let mut x = 0;
44-
while s[p] != b',' {
35+
while s[i] != b',' {
4536
x *= 10;
46-
x += (s[p] - b'0') as i64;
47-
p += 1;
37+
x += (s[i] - b'0') as i64;
38+
i += 1;
4839
}
4940
x += OFFSET;
50-
p += 4;
41+
i += 4;
5142

5243
let mut y = 0;
53-
while s[p] != b'\n' {
44+
while i < s.len() && s[i] != b'\n' {
5445
y *= 10;
55-
y += (s[p] - b'0') as i64;
56-
p += 1;
46+
y += (s[i] - b'0') as i64;
47+
i += 1;
5748
}
5849
y += OFFSET;
59-
p += 2;
60-
61-
*axs.get_unchecked_mut(i) = ax;
62-
*ays.get_unchecked_mut(i) = ay;
63-
*bxs.get_unchecked_mut(i) = bx;
64-
*bys.get_unchecked_mut(i) = by;
65-
*xs.get_unchecked_mut(i) = x;
66-
*ys.get_unchecked_mut(i) = y;
67-
i += 1;
68-
}
69-
70-
for i in 0..i {
71-
let ax = *axs.get_unchecked(i);
72-
let ay = *ays.get_unchecked(i);
73-
let bx = *bxs.get_unchecked(i);
74-
let by = *bys.get_unchecked(i);
75-
let x = *xs.get_unchecked(i);
76-
let y = *ys.get_unchecked(i);
50+
i += 2;
7751

7852
let numerator = x * by - y * bx;
7953
let denominator = ax * by - ay * bx;

0 commit comments

Comments
 (0)