diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-07-29 12:12:43 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-07-29 12:12:43 +0200 |
| commit | ea0387796a349c91032fbcb10f50c6ad8607b0f6 (patch) | |
| tree | aed484690d24c0c28c7695d4b5389f2e3c341b96 /src/arch | |
| parent | 52c21640508c3fc668107778ae027ff4428ebd89 (diff) | |
| download | nissy-core-ea0387796a349c91032fbcb10f50c6ad8607b0f6.tar.gz nissy-core-ea0387796a349c91032fbcb10f50c6ad8607b0f6.zip | |
All coordinates unsigned
Diffstat (limited to 'src/arch')
| -rw-r--r-- | src/arch/avx2.h | 60 | ||||
| -rw-r--r-- | src/arch/common.h | 36 | ||||
| -rw-r--r-- | src/arch/neon.h | 59 | ||||
| -rw-r--r-- | src/arch/portable.h | 32 |
4 files changed, 93 insertions, 94 deletions
diff --git a/src/arch/avx2.h b/src/arch/avx2.h index 7764c6b..24c8280 100644 --- a/src/arch/avx2.h +++ b/src/arch/avx2.h | |||
| @@ -25,8 +25,8 @@ | |||
| 25 | #define SOLVED_CUBE _mm256_set_epi64x(SOLVED_H, SOLVED_L, 0, SOLVED_L) | 25 | #define SOLVED_CUBE _mm256_set_epi64x(SOLVED_H, SOLVED_L, 0, SOLVED_L) |
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | STATIC_INLINE int64_t permtoindex_8x8(int64_t); | 28 | STATIC_INLINE uint64_t permtoindex_8x8(int64_t); |
| 29 | STATIC_INLINE int64_t indextoperm_8x8(int64_t); | 29 | STATIC_INLINE int64_t indextoperm_8x8(uint64_t); |
| 30 | 30 | ||
| 31 | STATIC_INLINE int | 31 | STATIC_INLINE int |
| 32 | popcount_u32(uint32_t x) | 32 | popcount_u32(uint32_t x) |
| @@ -144,11 +144,11 @@ inverse(cube_t c) | |||
| 144 | return invertco(ret); | 144 | return invertco(ret); |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | STATIC_INLINE int64_t | 147 | STATIC_INLINE uint64_t |
| 148 | coord_co(cube_t c) | 148 | coord_co(cube_t c) |
| 149 | { | 149 | { |
| 150 | cube_t co; | 150 | cube_t co; |
| 151 | int64_t mem[4], ret, i, p; | 151 | uint64_t mem[4], ret, i, p; |
| 152 | 152 | ||
| 153 | co = _mm256_and_si256(c, CO2_AVX2); | 153 | co = _mm256_and_si256(c, CO2_AVX2); |
| 154 | _mm256_storeu_si256((__m256i *)mem, co); | 154 | _mm256_storeu_si256((__m256i *)mem, co); |
| @@ -161,15 +161,15 @@ coord_co(cube_t c) | |||
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | STATIC_INLINE cube_t | 163 | STATIC_INLINE cube_t |
| 164 | invcoord_co(int64_t coord) | 164 | invcoord_co(uint64_t coord) |
| 165 | { | 165 | { |
| 166 | int64_t i, c, p, co, mem[4] = {0}; | 166 | uint64_t i, c, p, co, mem[4] = {0}; |
| 167 | cube_t cube, cc; | 167 | cube_t cube, cc; |
| 168 | 168 | ||
| 169 | for (i = 0, p = 0, c = coord; i < 8; i++, c /= 3) { | 169 | for (i = 0, p = 0, c = coord; i < 8; i++, c /= 3) { |
| 170 | co = i == 7 ? ((3 - (p % 3)) % 3) : (c % 3); | 170 | co = i == 7 ? ((3 - (p % 3)) % 3) : (c % 3); |
| 171 | p += co; | 171 | p += co; |
| 172 | mem[0] |= (int64_t)(i + (co << COSHIFT)) << (int64_t)(8 * i); | 172 | mem[0] |= (uint64_t)(i + (co << COSHIFT)) << (uint64_t)(8 * i); |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | cc = _mm256_loadu_si256((const __m256i *)mem); | 175 | cc = _mm256_loadu_si256((const __m256i *)mem); |
| @@ -179,43 +179,43 @@ invcoord_co(int64_t coord) | |||
| 179 | return cube; | 179 | return cube; |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | STATIC_INLINE int64_t | 182 | STATIC_INLINE uint64_t |
| 183 | coord_csep(cube_t c) | 183 | coord_csep(cube_t c) |
| 184 | { | 184 | { |
| 185 | cube_t cp, shifted; | 185 | cube_t cp, shifted; |
| 186 | int64_t mask; | 186 | int mask; |
| 187 | 187 | ||
| 188 | cp = _mm256_and_si256(c, CP_AVX2); | 188 | cp = _mm256_and_si256(c, CP_AVX2); |
| 189 | shifted = _mm256_slli_epi32(cp, 5); | 189 | shifted = _mm256_slli_epi32(cp, 5); |
| 190 | mask = _mm256_movemask_epi8(shifted); | 190 | mask = _mm256_movemask_epi8(shifted); |
| 191 | 191 | ||
| 192 | return mask & 0x7F; | 192 | return (uint64_t)(mask & 0x7F); |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | STATIC_INLINE int64_t | 195 | STATIC_INLINE uint64_t |
| 196 | coord_cocsep(cube_t c) | 196 | coord_cocsep(cube_t c) |
| 197 | { | 197 | { |
| 198 | return (coord_co(c) << 7) + coord_csep(c); | 198 | return (coord_co(c) << UINT8_C(7)) + coord_csep(c); |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | STATIC_INLINE int64_t | 201 | STATIC_INLINE uint64_t |
| 202 | coord_eo(cube_t c) | 202 | coord_eo(cube_t c) |
| 203 | { | 203 | { |
| 204 | cube_t eo, shifted; | 204 | cube_t eo, shifted; |
| 205 | int64_t mask; | 205 | int mask; |
| 206 | 206 | ||
| 207 | eo = _mm256_and_si256(c, EO_AVX2); | 207 | eo = _mm256_and_si256(c, EO_AVX2); |
| 208 | shifted = _mm256_slli_epi32(eo, 3); | 208 | shifted = _mm256_slli_epi32(eo, 3); |
| 209 | mask = _mm256_movemask_epi8(shifted); | 209 | mask = _mm256_movemask_epi8(shifted); |
| 210 | 210 | ||
| 211 | return mask >> 17; | 211 | return (uint64_t)(mask >> 17); |
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | STATIC_INLINE int64_t | 214 | STATIC_INLINE uint64_t |
| 215 | coord_esep(cube_t c) | 215 | coord_esep(cube_t c) |
| 216 | { | 216 | { |
| 217 | cube_t ep; | 217 | cube_t ep; |
| 218 | int64_t e, mem[4], i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; | 218 | uint64_t e, mem[4], i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; |
| 219 | 219 | ||
| 220 | ep = _mm256_and_si256(c, EP_AVX2); | 220 | ep = _mm256_and_si256(c, EP_AVX2); |
| 221 | _mm256_storeu_si256((__m256i *)mem, ep); | 221 | _mm256_storeu_si256((__m256i *)mem, ep); |
| @@ -243,12 +243,12 @@ coord_esep(cube_t c) | |||
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | STATIC_INLINE cube_t | 245 | STATIC_INLINE cube_t |
| 246 | invcoord_esep(int64_t esep) | 246 | invcoord_esep(uint64_t esep) |
| 247 | { | 247 | { |
| 248 | cube_t eee, ret; | 248 | cube_t eee, ret; |
| 249 | uint8_t mem[32] = {0}; | 249 | uint8_t mem[32] = {0}; |
| 250 | 250 | ||
| 251 | invcoord_esep_array(esep % 70, esep / 70, mem+16); | 251 | invcoord_esep_array(esep % UINT64_C(70), esep / UINT64_C(70), mem+16); |
| 252 | 252 | ||
| 253 | ret = SOLVED_CUBE; | 253 | ret = SOLVED_CUBE; |
| 254 | eee = _mm256_loadu_si256((__m256i_u *)&mem); | 254 | eee = _mm256_loadu_si256((__m256i_u *)&mem); |
| @@ -270,9 +270,9 @@ copy_edges(cube_t dest[static 1], cube_t src) | |||
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | STATIC_INLINE void | 272 | STATIC_INLINE void |
| 273 | set_eo(cube_t cube[static 1], int64_t eo) | 273 | set_eo(cube_t cube[static 1], uint64_t eo) |
| 274 | { | 274 | { |
| 275 | int64_t eo12, eotop, eobot; | 275 | uint64_t eo12, eotop, eobot; |
| 276 | __m256i veo; | 276 | __m256i veo; |
| 277 | 277 | ||
| 278 | eo12 = (eo << 1) + (_mm_popcnt_u64(eo) % 2); | 278 | eo12 = (eo << 1) + (_mm_popcnt_u64(eo) % 2); |
| @@ -294,17 +294,17 @@ set_eo(cube_t cube[static 1], int64_t eo) | |||
| 294 | *cube = _mm256_or_si256(*cube, veo); | 294 | *cube = _mm256_or_si256(*cube, veo); |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | STATIC_INLINE int64_t | 297 | STATIC_INLINE uint64_t |
| 298 | permtoindex_8x8(int64_t a) | 298 | permtoindex_8x8(int64_t a) |
| 299 | { | 299 | { |
| 300 | int64_t i, c, ret; | 300 | uint64_t i, c, ret; |
| 301 | __m64 cmp; | 301 | __m64 cmp; |
| 302 | 302 | ||
| 303 | for (i = 0, ret = 0; i < 8; i++) { | 303 | for (i = 0, ret = 0; i < 8; i++) { |
| 304 | cmp = _mm_set1_pi8(a & INT64_C(0xFF)); | 304 | cmp = _mm_set1_pi8(a & INT64_C(0xFF)); |
| 305 | a = (a >> INT64_C(8)) | INT64_C(0x0F00000000000000); | 305 | a = (a >> INT64_C(8)) | INT64_C(0x0F00000000000000); |
| 306 | cmp = _mm_cmpgt_pi8(cmp, _mm_cvtsi64_m64(a)); | 306 | cmp = _mm_cmpgt_pi8(cmp, _mm_cvtsi64_m64(a)); |
| 307 | c = _mm_popcnt_u64(_mm_cvtm64_si64(cmp)) >> INT64_C(3); | 307 | c = _mm_popcnt_u64(_mm_cvtm64_si64(cmp)) >> UINT64_C(3); |
| 308 | ret += c * factorial[7-i]; | 308 | ret += c * factorial[7-i]; |
| 309 | } | 309 | } |
| 310 | 310 | ||
| @@ -312,10 +312,10 @@ permtoindex_8x8(int64_t a) | |||
| 312 | } | 312 | } |
| 313 | 313 | ||
| 314 | STATIC_INLINE int64_t | 314 | STATIC_INLINE int64_t |
| 315 | indextoperm_8x8(int64_t p) | 315 | indextoperm_8x8(uint64_t p) |
| 316 | { | 316 | { |
| 317 | int used; | 317 | int used; |
| 318 | int64_t c, k, i, j, ret; | 318 | uint64_t c, k, i, j, ret; |
| 319 | 319 | ||
| 320 | for (i = 0, ret = 0, used = 0; i < 8; i++) { | 320 | for (i = 0, ret = 0, used = 0; i < 8; i++) { |
| 321 | k = p / factorial[7-i]; | 321 | k = p / factorial[7-i]; |
| @@ -332,7 +332,7 @@ indextoperm_8x8(int64_t p) | |||
| 332 | return ret; | 332 | return ret; |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | STATIC_INLINE int64_t | 335 | STATIC_INLINE uint64_t |
| 336 | coord_cp(cube_t cube) | 336 | coord_cp(cube_t cube) |
| 337 | { | 337 | { |
| 338 | cube_t cp; | 338 | cube_t cp; |
| @@ -345,12 +345,12 @@ coord_cp(cube_t cube) | |||
| 345 | } | 345 | } |
| 346 | 346 | ||
| 347 | STATIC_INLINE cube_t | 347 | STATIC_INLINE cube_t |
| 348 | invcoord_cp(int64_t i) | 348 | invcoord_cp(uint64_t i) |
| 349 | { | 349 | { |
| 350 | return _mm256_set_epi64x(SOLVED_H, SOLVED_L, 0, indextoperm_8x8(i)); | 350 | return _mm256_set_epi64x(SOLVED_H, SOLVED_L, 0, indextoperm_8x8(i)); |
| 351 | } | 351 | } |
| 352 | 352 | ||
| 353 | STATIC_INLINE int64_t | 353 | STATIC_INLINE uint64_t |
| 354 | coord_epud(cube_t cube) | 354 | coord_epud(cube_t cube) |
| 355 | { | 355 | { |
| 356 | cube_t ep; | 356 | cube_t ep; |
| @@ -363,7 +363,7 @@ coord_epud(cube_t cube) | |||
| 363 | } | 363 | } |
| 364 | 364 | ||
| 365 | STATIC_INLINE cube_t | 365 | STATIC_INLINE cube_t |
| 366 | invcoord_epud(int64_t i) | 366 | invcoord_epud(uint64_t i) |
| 367 | { | 367 | { |
| 368 | return _mm256_set_epi64x(SOLVED_H, indextoperm_8x8(i), 0, SOLVED_L); | 368 | return _mm256_set_epi64x(SOLVED_H, indextoperm_8x8(i), 0, SOLVED_L); |
| 369 | } | 369 | } |
diff --git a/src/arch/common.h b/src/arch/common.h index 3e7867d..6c62a2e 100644 --- a/src/arch/common.h +++ b/src/arch/common.h | |||
| @@ -22,30 +22,30 @@ STATIC_INLINE cube_t compose_corners(cube_t, cube_t); | |||
| 22 | STATIC_INLINE cube_t compose(cube_t, cube_t); | 22 | STATIC_INLINE cube_t compose(cube_t, cube_t); |
| 23 | STATIC_INLINE cube_t inverse(cube_t); | 23 | STATIC_INLINE cube_t inverse(cube_t); |
| 24 | 24 | ||
| 25 | STATIC_INLINE int64_t coord_co(cube_t); | 25 | STATIC_INLINE uint64_t coord_co(cube_t); |
| 26 | STATIC_INLINE cube_t invcoord_co(int64_t); | 26 | STATIC_INLINE cube_t invcoord_co(uint64_t); |
| 27 | STATIC_INLINE int64_t coord_csep(cube_t); | 27 | STATIC_INLINE uint64_t coord_csep(cube_t); |
| 28 | STATIC_INLINE int64_t coord_cocsep(cube_t); | 28 | STATIC_INLINE uint64_t coord_cocsep(cube_t); |
| 29 | STATIC_INLINE int64_t coord_eo(cube_t); | 29 | STATIC_INLINE uint64_t coord_eo(cube_t); |
| 30 | STATIC_INLINE int64_t coord_esep(cube_t); | 30 | STATIC_INLINE uint64_t coord_esep(cube_t); |
| 31 | STATIC_INLINE cube_t invcoord_esep(int64_t); | 31 | STATIC_INLINE cube_t invcoord_esep(uint64_t); |
| 32 | 32 | ||
| 33 | STATIC_INLINE void copy_corners(cube_t [static 1], cube_t); | 33 | STATIC_INLINE void copy_corners(cube_t [static 1], cube_t); |
| 34 | STATIC_INLINE void copy_edges(cube_t [static 1], cube_t); | 34 | STATIC_INLINE void copy_edges(cube_t [static 1], cube_t); |
| 35 | STATIC_INLINE void set_eo(cube_t [static 1], int64_t); | 35 | STATIC_INLINE void set_eo(cube_t [static 1], uint64_t); |
| 36 | 36 | ||
| 37 | STATIC_INLINE void invcoord_esep_array(int64_t, int64_t, uint8_t[static 12]); | 37 | STATIC_INLINE void invcoord_esep_array(uint64_t, uint64_t, uint8_t[static 12]); |
| 38 | STATIC_INLINE cube_t invcoord_eoesep(int64_t); | 38 | STATIC_INLINE cube_t invcoord_eoesep(uint64_t); |
| 39 | 39 | ||
| 40 | STATIC_INLINE int64_t coord_cp(cube_t); | 40 | STATIC_INLINE uint64_t coord_cp(cube_t); |
| 41 | STATIC_INLINE cube_t invcoord_cp(int64_t); | 41 | STATIC_INLINE cube_t invcoord_cp(uint64_t); |
| 42 | STATIC_INLINE int64_t coord_epud(cube_t); | 42 | STATIC_INLINE uint64_t coord_epud(cube_t); |
| 43 | STATIC_INLINE cube_t invcoord_epud(int64_t); | 43 | STATIC_INLINE cube_t invcoord_epud(uint64_t); |
| 44 | 44 | ||
| 45 | STATIC_INLINE void | 45 | STATIC_INLINE void |
| 46 | invcoord_esep_array(int64_t set1, int64_t set2, uint8_t mem[static 12]) | 46 | invcoord_esep_array(uint64_t set1, uint64_t set2, uint8_t mem[static 12]) |
| 47 | { | 47 | { |
| 48 | int64_t bit1, bit2, i, j, jj, k, l, s, v, w, is1; | 48 | uint64_t bit1, bit2, i, j, jj, k, l, s, v, w, is1; |
| 49 | uint8_t slice[3] = {0}; | 49 | uint8_t slice[3] = {0}; |
| 50 | 50 | ||
| 51 | for (i = 0, j = 0, k = 4, l = 4; i < 12; i++) | 51 | for (i = 0, j = 0, k = 4, l = 4; i < 12; i++) |
| @@ -69,10 +69,10 @@ invcoord_esep_array(int64_t set1, int64_t set2, uint8_t mem[static 12]) | |||
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | STATIC_INLINE cube_t | 71 | STATIC_INLINE cube_t |
| 72 | invcoord_eoesep(int64_t i) | 72 | invcoord_eoesep(uint64_t i) |
| 73 | { | 73 | { |
| 74 | cube_t c; | 74 | cube_t c; |
| 75 | int64_t esep, eo; | 75 | uint64_t esep, eo; |
| 76 | 76 | ||
| 77 | esep = i >> INT64_C(11); | 77 | esep = i >> INT64_C(11); |
| 78 | eo = i % POW_2_11; | 78 | eo = i % POW_2_11; |
diff --git a/src/arch/neon.h b/src/arch/neon.h index a378cf9..fef6220 100644 --- a/src/arch/neon.h +++ b/src/arch/neon.h | |||
| @@ -29,8 +29,8 @@ STATIC_INLINE uint8x8_t compose_corners_slim(uint8x8_t, uint8x8_t); | |||
| 29 | const uint8_t SOLVED_L[8] = {0, 1, 2, 3, 4, 5, 6, 7}; | 29 | const uint8_t SOLVED_L[8] = {0, 1, 2, 3, 4, 5, 6, 7}; |
| 30 | const uint8_t SOLVED_H[8] = {8, 9, 10, 11, 0, 0, 0}; | 30 | const uint8_t SOLVED_H[8] = {8, 9, 10, 11, 0, 0, 0}; |
| 31 | 31 | ||
| 32 | STATIC_INLINE int64_t permtoindex_8x8(uint8x8_t); | 32 | STATIC_INLINE uint64_t permtoindex_8x8(uint8x8_t); |
| 33 | STATIC_INLINE uint8x8_t indextoperm_8x8(int64_t); | 33 | STATIC_INLINE uint8x8_t indextoperm_8x8(uint64_t); |
| 34 | 34 | ||
| 35 | STATIC_INLINE int | 35 | STATIC_INLINE int |
| 36 | popcount_u32(uint32_t x) | 36 | popcount_u32(uint32_t x) |
| @@ -215,16 +215,15 @@ inverse(cube_t cube) | |||
| 215 | return ret; | 215 | return ret; |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | STATIC_INLINE int64_t | 218 | STATIC_INLINE uint64_t |
| 219 | coord_co(cube_t c) | 219 | coord_co(cube_t c) |
| 220 | { | 220 | { |
| 221 | uint64_t i, p, ret; | ||
| 222 | |||
| 221 | // Temp array to store the NEON vector | 223 | // Temp array to store the NEON vector |
| 222 | uint8_t mem[8]; | 224 | uint8_t mem[8]; |
| 223 | vst1_u8(mem, c.corner); | 225 | vst1_u8(mem, c.corner); |
| 224 | 226 | ||
| 225 | int i, p; | ||
| 226 | int64_t ret; | ||
| 227 | |||
| 228 | for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 3) | 227 | for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 3) |
| 229 | ret += p * (mem[i] >> COSHIFT); | 228 | ret += p * (mem[i] >> COSHIFT); |
| 230 | 229 | ||
| @@ -232,9 +231,9 @@ coord_co(cube_t c) | |||
| 232 | } | 231 | } |
| 233 | 232 | ||
| 234 | STATIC_INLINE cube_t | 233 | STATIC_INLINE cube_t |
| 235 | invcoord_co(int64_t coord) | 234 | invcoord_co(uint64_t coord) |
| 236 | { | 235 | { |
| 237 | int64_t co, c, i, p; | 236 | uint64_t co, c, i, p; |
| 238 | uint8_t mem[8]; | 237 | uint8_t mem[8]; |
| 239 | cube_t cube; | 238 | cube_t cube; |
| 240 | 239 | ||
| @@ -250,15 +249,15 @@ invcoord_co(int64_t coord) | |||
| 250 | return cube; | 249 | return cube; |
| 251 | } | 250 | } |
| 252 | 251 | ||
| 253 | STATIC_INLINE int64_t | 252 | STATIC_INLINE uint64_t |
| 254 | coord_csep(cube_t c) | 253 | coord_csep(cube_t c) |
| 255 | { | 254 | { |
| 255 | uint64_t ret, i, p; | ||
| 256 | |||
| 256 | // Temp array to store the NEON vector | 257 | // Temp array to store the NEON vector |
| 257 | uint8_t mem[8]; | 258 | uint8_t mem[8]; |
| 258 | vst1_u8(mem, c.corner); | 259 | vst1_u8(mem, c.corner); |
| 259 | 260 | ||
| 260 | int64_t ret = 0; | ||
| 261 | int i, p; | ||
| 262 | for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2) | 261 | for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2) |
| 263 | ret += p * ((mem[i] & CSEPBIT) >> 2); | 262 | ret += p * ((mem[i] & CSEPBIT) >> 2); |
| 264 | 263 | ||
| @@ -266,23 +265,23 @@ coord_csep(cube_t c) | |||
| 266 | return 0; | 265 | return 0; |
| 267 | } | 266 | } |
| 268 | 267 | ||
| 269 | STATIC_INLINE int64_t | 268 | STATIC_INLINE uint64_t |
| 270 | coord_cocsep(cube_t c) | 269 | coord_cocsep(cube_t c) |
| 271 | { | 270 | { |
| 272 | return (coord_co(c) << 7) + coord_csep(c); | 271 | return (coord_co(c) << UINT64_C(7)) + coord_csep(c); |
| 273 | } | 272 | } |
| 274 | 273 | ||
| 275 | STATIC_INLINE int64_t | 274 | STATIC_INLINE uint64_t |
| 276 | coord_eo(cube_t c) | 275 | coord_eo(cube_t c) |
| 277 | { | 276 | { |
| 278 | int64_t ret = 0; | 277 | uint64_t ret, p; |
| 279 | int64_t p = 1; | 278 | int i; |
| 280 | 279 | ||
| 281 | // Temp array to store the NEON vector | 280 | // Temp array to store the NEON vector |
| 282 | uint8_t mem[16]; | 281 | uint8_t mem[16]; |
| 283 | vst1q_u8(mem, c.edge); | 282 | vst1q_u8(mem, c.edge); |
| 284 | 283 | ||
| 285 | for (int i = 1; i < 12; i++, p *= 2) | 284 | for (i = 1, ret = 0, p = 1; i < 12; i++, p *= 2) |
| 286 | { | 285 | { |
| 287 | ret += p * (mem[i] >> EOSHIFT); | 286 | ret += p * (mem[i] >> EOSHIFT); |
| 288 | } | 287 | } |
| @@ -290,10 +289,10 @@ coord_eo(cube_t c) | |||
| 290 | return ret; | 289 | return ret; |
| 291 | } | 290 | } |
| 292 | 291 | ||
| 293 | STATIC_INLINE int64_t | 292 | STATIC_INLINE uint64_t |
| 294 | coord_esep(cube_t c) | 293 | coord_esep(cube_t c) |
| 295 | { | 294 | { |
| 296 | int64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; | 295 | uint64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; |
| 297 | 296 | ||
| 298 | // Temp array to store the NEON vector | 297 | // Temp array to store the NEON vector |
| 299 | uint8_t mem[16]; | 298 | uint8_t mem[16]; |
| @@ -330,7 +329,7 @@ copy_edges(cube_t dst[static 1], cube_t src) | |||
| 330 | } | 329 | } |
| 331 | 330 | ||
| 332 | STATIC_INLINE void | 331 | STATIC_INLINE void |
| 333 | set_eo(cube_t cube[static 1], int64_t eo) | 332 | set_eo(cube_t cube[static 1], uint64_t eo) |
| 334 | { | 333 | { |
| 335 | // Temp array to store the NEON vector | 334 | // Temp array to store the NEON vector |
| 336 | uint8_t mem[16]; | 335 | uint8_t mem[16]; |
| @@ -351,12 +350,12 @@ set_eo(cube_t cube[static 1], int64_t eo) | |||
| 351 | } | 350 | } |
| 352 | 351 | ||
| 353 | STATIC_INLINE cube_t | 352 | STATIC_INLINE cube_t |
| 354 | invcoord_esep(int64_t esep) | 353 | invcoord_esep(uint64_t esep) |
| 355 | { | 354 | { |
| 356 | cube_t ret; | 355 | cube_t ret; |
| 357 | uint8_t mem[16] = {0}; | 356 | uint8_t mem[16] = {0}; |
| 358 | 357 | ||
| 359 | invcoord_esep_array(esep % 70, esep / 70, mem); | 358 | invcoord_esep_array(esep % UINT64_C(70), esep / UINT64_C(70), mem); |
| 360 | 359 | ||
| 361 | ret = SOLVED_CUBE; | 360 | ret = SOLVED_CUBE; |
| 362 | ret.edge = vld1q_u8(mem); | 361 | ret.edge = vld1q_u8(mem); |
| @@ -364,10 +363,10 @@ invcoord_esep(int64_t esep) | |||
| 364 | return ret; | 363 | return ret; |
| 365 | } | 364 | } |
| 366 | 365 | ||
| 367 | STATIC_INLINE int64_t | 366 | STATIC_INLINE uint64_t |
| 368 | permtoindex_8x8(uint8x8_t a) | 367 | permtoindex_8x8(uint8x8_t a) |
| 369 | { | 368 | { |
| 370 | int64_t i, c, ret; | 369 | uint64_t i, c, ret; |
| 371 | uint8x8_t cmp; | 370 | uint8x8_t cmp; |
| 372 | uint64x1_t anum; | 371 | uint64x1_t anum; |
| 373 | uint8_t or[8] = {0, 0, 0, 0, 0, 0, 0, 0x0F}; | 372 | uint8_t or[8] = {0, 0, 0, 0, 0, 0, 0, 0x0F}; |
| @@ -387,10 +386,10 @@ permtoindex_8x8(uint8x8_t a) | |||
| 387 | } | 386 | } |
| 388 | 387 | ||
| 389 | STATIC_INLINE uint8x8_t | 388 | STATIC_INLINE uint8x8_t |
| 390 | indextoperm_8x8(int64_t p) | 389 | indextoperm_8x8(uint64_t p) |
| 391 | { | 390 | { |
| 392 | int used; | 391 | int used; |
| 393 | int64_t c, k, i, j; | 392 | uint64_t c, k, i, j; |
| 394 | uint8_t ret[8]; | 393 | uint8_t ret[8]; |
| 395 | 394 | ||
| 396 | for (i = 0, used = 0; i < 8; i++) { | 395 | for (i = 0, used = 0; i < 8; i++) { |
| @@ -408,14 +407,14 @@ indextoperm_8x8(int64_t p) | |||
| 408 | return vld1_u8(ret); | 407 | return vld1_u8(ret); |
| 409 | } | 408 | } |
| 410 | 409 | ||
| 411 | STATIC_INLINE int64_t | 410 | STATIC_INLINE uint64_t |
| 412 | coord_cp(cube_t cube) | 411 | coord_cp(cube_t cube) |
| 413 | { | 412 | { |
| 414 | return permtoindex_8x8(vand_u8(cube.corner, PBITS8_NEON)); | 413 | return permtoindex_8x8(vand_u8(cube.corner, PBITS8_NEON)); |
| 415 | } | 414 | } |
| 416 | 415 | ||
| 417 | STATIC_INLINE cube_t | 416 | STATIC_INLINE cube_t |
| 418 | invcoord_cp(int64_t i) | 417 | invcoord_cp(uint64_t i) |
| 419 | { | 418 | { |
| 420 | return (cube_t) { | 419 | return (cube_t) { |
| 421 | .corner = indextoperm_8x8(i), | 420 | .corner = indextoperm_8x8(i), |
| @@ -423,14 +422,14 @@ invcoord_cp(int64_t i) | |||
| 423 | }; | 422 | }; |
| 424 | } | 423 | } |
| 425 | 424 | ||
| 426 | STATIC_INLINE int64_t | 425 | STATIC_INLINE uint64_t |
| 427 | coord_epud(cube_t cube) | 426 | coord_epud(cube_t cube) |
| 428 | { | 427 | { |
| 429 | return permtoindex_8x8(vand_u8(vget_low_u8(cube.edge), PBITS8_NEON)); | 428 | return permtoindex_8x8(vand_u8(vget_low_u8(cube.edge), PBITS8_NEON)); |
| 430 | } | 429 | } |
| 431 | 430 | ||
| 432 | STATIC_INLINE cube_t | 431 | STATIC_INLINE cube_t |
| 433 | invcoord_epud(int64_t i) | 432 | invcoord_epud(uint64_t i) |
| 434 | { | 433 | { |
| 435 | return (cube_t) { | 434 | return (cube_t) { |
| 436 | .corner = vld1_u8(SOLVED_L), | 435 | .corner = vld1_u8(SOLVED_L), |
diff --git a/src/arch/portable.h b/src/arch/portable.h index ec992a8..5acccf2 100644 --- a/src/arch/portable.h +++ b/src/arch/portable.h | |||
| @@ -154,7 +154,7 @@ inverse(cube_t cube) | |||
| 154 | return ret; | 154 | return ret; |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | STATIC_INLINE int64_t | 157 | STATIC_INLINE uint64_t |
| 158 | coord_co(cube_t c) | 158 | coord_co(cube_t c) |
| 159 | { | 159 | { |
| 160 | int i, p, ret; | 160 | int i, p, ret; |
| @@ -166,9 +166,9 @@ coord_co(cube_t c) | |||
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | STATIC_INLINE cube_t | 168 | STATIC_INLINE cube_t |
| 169 | invcoord_co(int64_t coord) | 169 | invcoord_co(uint64_t coord) |
| 170 | { | 170 | { |
| 171 | int64_t i, c, p; | 171 | uint64_t i, c, p; |
| 172 | cube_t cube; | 172 | cube_t cube; |
| 173 | 173 | ||
| 174 | cube = SOLVED_CUBE; | 174 | cube = SOLVED_CUBE; |
| @@ -189,11 +189,11 @@ Ignoring the last bit, we have a value up to 2^7, but not all values are | |||
| 189 | possible. Encoding this as a number from 0 to C(8,4) would save about 40% | 189 | possible. Encoding this as a number from 0 to C(8,4) would save about 40% |
| 190 | of space, but we are not going to use this coordinate in large tables. | 190 | of space, but we are not going to use this coordinate in large tables. |
| 191 | */ | 191 | */ |
| 192 | STATIC_INLINE int64_t | 192 | STATIC_INLINE uint64_t |
| 193 | coord_csep(cube_t c) | 193 | coord_csep(cube_t c) |
| 194 | { | 194 | { |
| 195 | int i, p; | 195 | int i, p; |
| 196 | int64_t ret; | 196 | uint64_t ret; |
| 197 | 197 | ||
| 198 | for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2) | 198 | for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2) |
| 199 | ret += p * ((c.corner[i] & CSEPBIT) >> 2); | 199 | ret += p * ((c.corner[i] & CSEPBIT) >> 2); |
| @@ -201,17 +201,17 @@ coord_csep(cube_t c) | |||
| 201 | return ret; | 201 | return ret; |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | STATIC_INLINE int64_t | 204 | STATIC_INLINE uint64_t |
| 205 | coord_cocsep(cube_t c) | 205 | coord_cocsep(cube_t c) |
| 206 | { | 206 | { |
| 207 | return (coord_co(c) << 7) + coord_csep(c); | 207 | return (coord_co(c) << 7) + coord_csep(c); |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | STATIC_INLINE int64_t | 210 | STATIC_INLINE uint64_t |
| 211 | coord_eo(cube_t c) | 211 | coord_eo(cube_t c) |
| 212 | { | 212 | { |
| 213 | int i, p; | 213 | int i, p; |
| 214 | int64_t ret; | 214 | uint64_t ret; |
| 215 | 215 | ||
| 216 | for (ret = 0, i = 1, p = 1; i < 12; i++, p *= 2) | 216 | for (ret = 0, i = 1, p = 1; i < 12; i++, p *= 2) |
| 217 | ret += p * (c.edge[i] >> EOSHIFT); | 217 | ret += p * (c.edge[i] >> EOSHIFT); |
| @@ -223,10 +223,10 @@ coord_eo(cube_t c) | |||
| 223 | We encode the edge separation as a number from 0 to C(12,4)*C(8,4). | 223 | We encode the edge separation as a number from 0 to C(12,4)*C(8,4). |
| 224 | It can be seen as the composition of two "subset index" coordinates. | 224 | It can be seen as the composition of two "subset index" coordinates. |
| 225 | */ | 225 | */ |
| 226 | STATIC_INLINE int64_t | 226 | STATIC_INLINE uint64_t |
| 227 | coord_esep(cube_t c) | 227 | coord_esep(cube_t c) |
| 228 | { | 228 | { |
| 229 | int64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; | 229 | uint64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; |
| 230 | 230 | ||
| 231 | for (i = 0, j = 0, k = 4, l = 4, ret1 = 0, ret2 = 0; i < 12; i++) { | 231 | for (i = 0, j = 0, k = 4, l = 4, ret1 = 0, ret2 = 0; i < 12; i++) { |
| 232 | /* Simple version: | 232 | /* Simple version: |
| @@ -256,7 +256,7 @@ coord_esep(cube_t c) | |||
| 256 | } | 256 | } |
| 257 | 257 | ||
| 258 | STATIC_INLINE cube_t | 258 | STATIC_INLINE cube_t |
| 259 | invcoord_esep(int64_t esep) | 259 | invcoord_esep(uint64_t esep) |
| 260 | { | 260 | { |
| 261 | cube_t ret; | 261 | cube_t ret; |
| 262 | 262 | ||
| @@ -279,7 +279,7 @@ copy_edges(cube_t dest[static 1], cube_t src) | |||
| 279 | } | 279 | } |
| 280 | 280 | ||
| 281 | STATIC_INLINE void | 281 | STATIC_INLINE void |
| 282 | set_eo(cube_t cube[static 1], int64_t eo) | 282 | set_eo(cube_t cube[static 1], uint64_t eo) |
| 283 | { | 283 | { |
| 284 | uint8_t i, sum, flip; | 284 | uint8_t i, sum, flip; |
| 285 | 285 | ||
| @@ -291,7 +291,7 @@ set_eo(cube_t cube[static 1], int64_t eo) | |||
| 291 | cube->edge[0] = (cube->edge[0] & ~EOBIT) | (EOBIT * (sum % 2)); | 291 | cube->edge[0] = (cube->edge[0] & ~EOBIT) | (EOBIT * (sum % 2)); |
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | STATIC_INLINE int64_t | 294 | STATIC_INLINE uint64_t |
| 295 | coord_cp(cube_t cube) | 295 | coord_cp(cube_t cube) |
| 296 | { | 296 | { |
| 297 | int i; | 297 | int i; |
| @@ -303,7 +303,7 @@ coord_cp(cube_t cube) | |||
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | STATIC_INLINE cube_t | 305 | STATIC_INLINE cube_t |
| 306 | invcoord_cp(int64_t i) | 306 | invcoord_cp(uint64_t i) |
| 307 | { | 307 | { |
| 308 | uint8_t c[8]; | 308 | uint8_t c[8]; |
| 309 | 309 | ||
| @@ -313,7 +313,7 @@ invcoord_cp(int64_t i) | |||
| 313 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); | 313 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); |
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | STATIC_INLINE int64_t | 316 | STATIC_INLINE uint64_t |
| 317 | coord_epud(cube_t cube) | 317 | coord_epud(cube_t cube) |
| 318 | { | 318 | { |
| 319 | int i; | 319 | int i; |
| @@ -325,7 +325,7 @@ coord_epud(cube_t cube) | |||
| 325 | } | 325 | } |
| 326 | 326 | ||
| 327 | STATIC_INLINE cube_t | 327 | STATIC_INLINE cube_t |
| 328 | invcoord_epud(int64_t i) | 328 | invcoord_epud(uint64_t i) |
| 329 | { | 329 | { |
| 330 | uint8_t e[8]; | 330 | uint8_t e[8]; |
| 331 | 331 | ||
