From 80b065f757240af7920862b3e09f32a6dc06d392 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Fri, 4 Oct 2024 12:01:41 +0200 Subject: Table-based transformations (will revert immediately) This commit changes transformations to being based on a lookup table intead of a big switch. This is something I had planned for a long time and the code is nicer with this change. But unfortunately the performance is noticeably worse, so I'll revert all these changes in the next commit. I wanted to push this anyway so we can keep track of this. --- src/arch/avx2.h | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'src/arch/avx2.h') diff --git a/src/arch/avx2.h b/src/arch/avx2.h index 2c3371e..557ab49 100644 --- a/src/arch/avx2.h +++ b/src/arch/avx2.h @@ -6,16 +6,6 @@ #define EO_AVX2 \ _mm256_set_epi64x(INT64_C(0x10101010), INT64_C(0x1010101010101010), 0, 0) -#define STATIC_CUBE(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \ - e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, e_fl, e_bl, e_br) \ - _mm256_set_epi8(0, 0, 0, 0, e_br, e_bl, e_fl, e_fr, \ - e_dr, e_dl, e_ul, e_ur, e_df, e_db, e_ub, e_uf, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - c_dbl, c_dfr, c_ubr, c_ufl, c_dbr, c_dfl, c_ubl, c_ufr) -#define ZERO_CUBE _mm256_set_epi64x(0, 0, 0, 0) -#define SOLVED_CUBE STATIC_CUBE( \ - 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) - STATIC void pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) { @@ -26,6 +16,38 @@ pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) memcpy(e, aux+16, 12); } +STATIC_INLINE cube_t +cubefrompieces( + uint8_t c_ufr, + uint8_t c_ubl, + uint8_t c_dfl, + uint8_t c_dbr, + uint8_t c_ufl, + uint8_t c_ubr, + uint8_t c_dfr, + uint8_t c_dbl, + + uint8_t e_uf, + uint8_t e_ub, + uint8_t e_db, + uint8_t e_df, + uint8_t e_ur, + uint8_t e_ul, + uint8_t e_dl, + uint8_t e_dr, + uint8_t e_fr, + uint8_t e_fl, + uint8_t e_bl, + uint8_t e_br +) { + return _mm256_set_epi8( + 0, 0, 0, 0, e_br, e_bl, e_fl, e_fr, + e_dr, e_dl, e_ul, e_ur, e_df, e_db, e_ub, e_uf, + 0, 0, 0, 0, 0, 0, 0, 0, + c_dbl, c_dfr, c_ubr, c_ufl, c_dbr, c_dfl, c_ubl, c_ufr + ); +} + STATIC_INLINE bool equal(cube_t c1, cube_t c2) { -- cgit v1.3