Open gzm55 opened 3 years ago
If SSSE3 can be assumed to be present (#include <immintrin.h>
, #ifdef __SSSE3__
), that would be the PSHUFB
instruction or _mm_shuffle_epi8()
intrinsic along with 128-bit XMM register store and read back (MOVD
/ MOVQ
).
Tiny challenge here: The randomized parameter to PSHUFB
itself needs to be a permutation of 0x00
... 0x03
/ 0x07
. This could be solved by starting off from 0x00
... 0x07
and randomly exchanging the values pairwise, e.g. four n x (n-1) times length = 32 times required (this is still somewhat flaky with a view to equi-distributed permutations).
Bytes shuffling is another reversible operation and the effects should between mul and xorshift.