I am (mostly for fun) attempting to write a SHA-256 digest function using Java's Vector API. I am using the following AVX2 implementation from bitcoin as a reference:
I have been able to make it to the point where the shuffle intrinsic is used: return _mm256_shuffle_epi8(ret, _mm256_set_epi32(0x0C0D0E0FUL, 0x08090A0BUL, 0x04050607UL, 0x00010203UL, 0x0C0D0E0FUL, 0x08090A0BUL, 0x04050607UL, 0x00010203UL));
.
I see that the Java Vector API provides a VectorShuffle
class and rearrange
methods on the Vector
class but the API docs seem to be approaching shuffles from the angle of indexes and not masks.
So my question is - how to replicate (as close as possible) the behavior of the _mm256_shuffle_epi8
intrinsic with Java's vector API?
Update: I just realized that the AVX2 SHA-256 bitcoin implementation seems to be a Double SHA-256 implementation. This complicates matters...