aboutsummaryrefslogtreecommitdiff
path: root/src/solve_h48.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-05-25 17:56:47 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-05-25 17:56:47 +0200
commit1833e9c0ba37b90a5db84cecc66388d83f37d36a (patch)
tree3c584191c36b3072b1cb3096a308002ba4b58f6e /src/solve_h48.h
parent43020af69d6932c7af0bc53b59c492775835a14e (diff)
downloadnissy-core-1833e9c0ba37b90a5db84cecc66388d83f37d36a.tar.gz
nissy-core-1833e9c0ba37b90a5db84cecc66388d83f37d36a.zip
Fixed a NASTY bug with type promotions in generation of "selfsim".
That was very hard to test because I have not way to know the actual answer beforehand. Luckily I caught it.
Diffstat (limited to 'src/solve_h48.h')
-rw-r--r--src/solve_h48.h26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/solve_h48.h b/src/solve_h48.h
index d08fc72..a2e3184 100644
--- a/src/solve_h48.h
+++ b/src/solve_h48.h
@@ -1,6 +1,6 @@
1#define COCSEP_CLASSES 3393U 1#define COCSEP_CLASSES 3393U
2#define COCSEP_TABLESIZE (_3p7 << 7U) 2#define COCSEP_TABLESIZE (_3p7 << 7ULL)
3#define COCSEP_VISITEDSIZE ((COCSEP_TABLESIZE + 7U) / 8U) 3#define COCSEP_VISITEDSIZE ((COCSEP_TABLESIZE + 7ULL) / 8ULL)
4#define COCSEP_FULLSIZE (4*(COCSEP_TABLESIZE + 12)) 4#define COCSEP_FULLSIZE (4*(COCSEP_TABLESIZE + 12))
5 5
6#define ESEP_MAX(h) ((COCSEP_CLASSES * _12c4 * _8c4) << (h)) 6#define ESEP_MAX(h) ((COCSEP_CLASSES * _12c4 * _8c4) << (h))
@@ -8,11 +8,11 @@
8 8
9#define H48_ESIZE(h) ((_12c4 * _8c4) << (h)) 9#define H48_ESIZE(h) ((_12c4 * _8c4) << (h))
10 10
11#define _esep_ind(i) (i / 8U) 11#define _esep_ind(i) (i / 8ULL)
12#define _esep_shift(i) (4U * (i % 8U)) 12#define _esep_shift(i) (4ULL * (i % 8ULL))
13#define _esep_mask(i) (((1U << 4U) - 1U) << _esep_shift(i)) 13#define _esep_mask(i) (((1ULL << 4ULL) - 1ULL) << _esep_shift(i))
14#define _visited_ind(i) (i / 8U) 14#define _visited_ind(i) (i / 8ULL)
15#define _visited_mask(i) (1U << (i % 8U)) 15#define _visited_mask(i) (1ULL << (i % 8ULL))
16 16
17typedef struct { 17typedef struct {
18 cube_fast_t cube; 18 cube_fast_t cube;
@@ -163,8 +163,9 @@ gendata_cocsep(void *buf, uint64_t *selfsim, cube_fast_t *rep)
163_static uint32_t 163_static uint32_t
164gendata_cocsep_dfs(dfsarg_cocsep_t *arg) 164gendata_cocsep_dfs(dfsarg_cocsep_t *arg)
165{ 165{
166 uint8_t m, t, tinv, olddepth; 166 uint8_t m, tinv, olddepth;
167 uint32_t cc; 167 uint32_t cc;
168 uint64_t t, is;
168 int64_t i, ii; 169 int64_t i, ii;
169 cube_fast_t d; 170 cube_fast_t d;
170 dfsarg_cocsep_t nextarg; 171 dfsarg_cocsep_t nextarg;
@@ -182,7 +183,8 @@ gendata_cocsep_dfs(dfsarg_cocsep_t *arg)
182 for (t = 0, cc = 0; t < 48; t++) { 183 for (t = 0, cc = 0; t < 48; t++) {
183 d = transform_corners(arg->cube, t); 184 d = transform_corners(arg->cube, t);
184 ii = coord_fast_cocsep(d); 185 ii = coord_fast_cocsep(d);
185 arg->selfsim[*arg->n] |= (i == ii) << t; 186 is = (i == ii);
187 arg->selfsim[*arg->n] |= is << t;
186 set_visited(arg->visited, ii); 188 set_visited(arg->visited, ii);
187 tinv = inverse_trans(t); 189 tinv = inverse_trans(t);
188 cc += (arg->buf32[ii] & 0xFFU) == 0xFFU; 190 cc += (arg->buf32[ii] & 0xFFU) == 0xFFU;
@@ -262,9 +264,9 @@ gendata_h48(void *buf, uint8_t h, uint8_t maxdepth)
262_static uint64_t 264_static uint64_t
263gendata_esep_bfs(bfsarg_esep_t *arg) 265gendata_esep_bfs(bfsarg_esep_t *arg)
264{ 266{
265 uint8_t c, m, t, x; 267 uint8_t c, m, x;
266 uint32_t cc; 268 uint32_t cc;
267 uint64_t i, j, k, cocsep_coord, sim; 269 uint64_t i, j, k, t, cocsep_coord, sim;
268 cube_fast_t cube, moved, transd; 270 cube_fast_t cube, moved, transd;
269 271
270 for (i = 0, cc = 0; i < ESEP_MAX(arg->h); i++) { 272 for (i = 0, cc = 0; i < ESEP_MAX(arg->h); i++) {
@@ -288,7 +290,7 @@ gendata_esep_bfs(bfsarg_esep_t *arg)
288 cocsep_coord = j / H48_ESIZE(arg->h); 290 cocsep_coord = j / H48_ESIZE(arg->h);
289 sim = arg->selfsim[cocsep_coord]; 291 sim = arg->selfsim[cocsep_coord];
290 for (t = 1; t < 48; t++) { /* Skip trivial trans */ 292 for (t = 1; t < 48; t++) { /* Skip trivial trans */
291 if (!(sim & (1 << t))) 293 if (!(sim & (1ULL << t)))
292 continue; 294 continue;
293 transd = transform(moved, t); 295 transd = transform(moved, t);
294 k = coord_h48(transd, arg->cocsepdata, arg->h); 296 k = coord_h48(transd, arg->cocsepdata, arg->h);

Generated with cgit - Back to sebastiano.tronto.net