I have an avx2 implementation of cryptographic hash LSH512-512 with context implementation:
typedef struct st_lsh512_avx2_context {
size_t bidx;
size_t length;
alignas(32) simde__m256i block[8];
alignas(32) simde__m256i cv[4];
alignas(32) simde__m256i tcv[4];
alignas(32) simde__m256i msg[4 * (28 + 1)];
} lsh512_avx2_context;
The correct digest of string "Hello world!":
68d4f699 4079d4ad 646d1cdc 584da536 752ef210 1d2d1ffa 497b79e8 d020f89e
3fa9be21 7ce625d3 43405ab5 c6813beb a63cc717 d9fff43f 587c736f fb0491dc
However, when I try to change the alignment specifically, the structure breaks. The code remains unchanged, the digest gets changed randomly. The updated context structure:
typedef struct st_lsh512_avx2_context {
size_t bidx;
size_t length;
alignas(64) simde__m256i block[4];
alignas(32) simde__m256i cv[4];
alignas(32) simde__m256i tcv[4];
alignas(64) simde__m256i msg[4 * (28 + 1)];
} lsh512_avx2_context;
I'm using SIMDe library to make AVX512 portable everywhere, thus it's not the problem in intrinsic support. Moreover, even when I just change the alignment to 64 bytes while leaving the structure untouched, both produce the same weird output:
87645c6f 323dd9fc 7652cd95 52f7be94 5cb51cc6 9311a55c 121f6219 5aee6321
b537ee94 62a05d23 74d5f86e 33ad1418 5edd2823 478f81eb 81d74c50 12549db0
I'm unable to explain such behavior.