aboutsummaryrefslogtreecommitdiff
path: root/src/arch/avx2.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-03-26 19:22:50 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-03-26 19:22:50 +0100
commit83338a2f753ebbb7ba7b154cc60b2f427b6121b0 (patch)
tree149efb6a0b835fd6b3d89f7fd7808f8eed8e0288 /src/arch/avx2.h
parent56048d13b73ec6e6a9c59d62e82f41e69a3994bd (diff)
downloadnissy-core-83338a2f753ebbb7ba7b154cc60b2f427b6121b0.tar.gz
nissy-core-83338a2f753ebbb7ba7b154cc60b2f427b6121b0.zip
Added inverse coordinate for CO
this is necessary for DR coordinate
Diffstat (limited to 'src/arch/avx2.h')
-rw-r--r--src/arch/avx2.h49
1 files changed, 34 insertions, 15 deletions
diff --git a/src/arch/avx2.h b/src/arch/avx2.h
index ebcf84f..4682e33 100644
--- a/src/arch/avx2.h
+++ b/src/arch/avx2.h
@@ -188,6 +188,25 @@ coord_co(cube_t c)
188 return ret; 188 return ret;
189} 189}
190 190
191STATIC_INLINE cube_t
192invcoord_co(int64_t coord)
193{
194 int64_t i, c, p, co, mem[4] = {0};
195 cube_t cube, cc;
196
197 for (i = 0, p = 0, c = coord; i < 8; i++, c /= 3) {
198 co = i == 7 ? ((3 - (p % 3)) % 3) : (c % 3);
199 p += co;
200 mem[0] |= (int64_t)(i + (co << COSHIFT)) << (int64_t)(8 * i);
201 }
202
203 cc = _mm256_loadu_si256((const __m256i *)mem);
204 cube = SOLVED_CUBE;
205 copy_corners(&cube, cc);
206
207 return cube;
208}
209
191STATIC_INLINE int64_t 210STATIC_INLINE int64_t
192coord_csep(cube_t c) 211coord_csep(cube_t c)
193{ 212{
@@ -251,6 +270,21 @@ coord_esep(cube_t c)
251 return ret1 * 70 + ret2; 270 return ret1 * 70 + ret2;
252} 271}
253 272
273STATIC_INLINE cube_t
274invcoord_esep(int64_t esep)
275{
276 cube_t eee, ret;
277 uint8_t mem[32] = {0};
278
279 invcoord_esep_array(esep % 70, esep / 70, mem+16);
280
281 ret = SOLVED_CUBE;
282 eee = _mm256_loadu_si256((__m256i_u *)&mem);
283 copy_edges(&ret, eee);
284
285 return ret;
286}
287
254STATIC_INLINE void 288STATIC_INLINE void
255copy_corners(cube_t dest[static 1], cube_t src) 289copy_corners(cube_t dest[static 1], cube_t src)
256{ 290{
@@ -287,18 +321,3 @@ set_eo(cube_t cube[static 1], int64_t eo)
287 *cube = _mm256_andnot_si256(EO_AVX2, *cube); 321 *cube = _mm256_andnot_si256(EO_AVX2, *cube);
288 *cube = _mm256_or_si256(*cube, veo); 322 *cube = _mm256_or_si256(*cube, veo);
289} 323}
290
291STATIC_INLINE cube_t
292invcoord_esep(int64_t esep)
293{
294 cube_t eee, ret;
295 uint8_t mem[32] = {0};
296
297 invcoord_esep_array(esep % 70, esep / 70, mem+16);
298
299 ret = SOLVED_CUBE;
300 eee = _mm256_loadu_si256((__m256i_u *)&mem);
301 copy_edges(&ret, eee);
302
303 return ret;
304}

Generated with cgit - Back to sebastiano.tronto.net