Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OP-REQ: byte shuffle for 64bit or 32bit operation #7

Open
gzm55 opened this issue Mar 25, 2021 · 2 comments · May be fixed by #13
Open

OP-REQ: byte shuffle for 64bit or 32bit operation #7

gzm55 opened this issue Mar 25, 2021 · 2 comments · May be fixed by #13

Comments

@gzm55
Copy link

gzm55 commented Mar 25, 2021

Bytes shuffling is another reversible operation and the effects should between mul and xorshift.

@Logan007
Copy link
Contributor

Logan007 commented Mar 25, 2021

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).

@gzm55
Copy link
Author

gzm55 commented Mar 25, 2021

Since the op is run as jit x86 codes, it could be always assumed as true to get SSSE3 instructions, otherwise this op can be force disabled.

The shuffle algorithm could help to generate the parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants