Skip to content

Commit 268f18a

Browse files
committed
fixup
1 parent e34e7bf commit 268f18a

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

c/hv4d.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,18 @@ _attr_optimize_finite_math
108108
__attribute__((hot)) static bool
109109
restart_base_setup_z_and_closest(dlnode_t * restrict list, dlnode_t * restrict new)
110110
{
111-
const double newx[] = { new->x[0], new->x[1], new->x[2] };
112111
// FIXME: This is the most expensive function in the HV4D+ algorithm.
112+
const double newx[] = { new->x[0], new->x[1], new->x[2] };
113113
assert(list+1 == list->next[0]);
114114
dlnode_t * closest0 = list+1;
115115
dlnode_t * closest1 = list;
116-
double closest0x[] = { closest0->x[0], closest0->x[1] };
117-
double closest1x[] = { closest1->x[0], closest1->x[1] };
116+
const double * closest0x = closest0->x;
117+
const double * closest1x = closest1->x;
118118
dlnode_t * p = (list+1)->next[0];
119119
assert(p == list->next[0]->next[0]);
120120
restart_list_y(list);
121121
while (true) {
122-
const double px[] = { p->x[0], p->x[1], p->x[2] };
122+
const double * restrict px = p->x;
123123
// Help auto-vectorization.
124124
bool p_lt_new_0 = px[0] < newx[0];
125125
bool p_lt_new_1 = px[1] < newx[1];
@@ -133,12 +133,12 @@ restart_base_setup_z_and_closest(dlnode_t * restrict list, dlnode_t * restrict n
133133

134134
if (p_leq_new_0 & p_leq_new_1 & p_leq_new_2) {
135135
//new->ndomr++;
136-
assert(weakly_dominates(px, newx, 4));
136+
assert(weakly_dominates(p->x, new->x, 4));
137137
return false;
138138
}
139139

140-
// if (!lexicographic_less_3d(px, newx))
141-
if (!(p_lt_new_2 || (p_eq_new_2 && (p_lt_new_1 || (p_eq_new_1 && !p_leq_new_0))))) {
140+
if (!lexicographic_less_3d(px, newx)) {
141+
// if (!(p_lt_new_2 || (p_eq_new_2 && (p_lt_new_1 || (p_eq_new_1 && !p_leq_new_0))))) {
142142
new->closest[0] = closest0;
143143
new->closest[1] = closest1;
144144
new->prev[0] = p->prev[0];
@@ -156,12 +156,10 @@ restart_base_setup_z_and_closest(dlnode_t * restrict list, dlnode_t * restrict n
156156
ASSUME(!p_leq_new_0 || !p_leq_new_1);
157157
if (p_lt_new_1 && (px[0] < closest0x[0] || (px[0] == closest0x[0] && px[1] < closest0x[1]))) {
158158
closest0 = p;
159-
closest0x[0] = px[0];
160-
closest0x[1] = px[1];
159+
closest0x = px;
161160
} else if (p_lt_new_0 && (px[1] < closest1x[1] || (px[1] == closest1x[1] && px[0] < closest1x[0]))) {
162161
closest1 = p;
163-
closest1x[0] = px[0];
164-
closest1x[1] = px[1];
162+
closest1x = px;
165163
}
166164
p = p->next[0];
167165
}

0 commit comments

Comments
 (0)