| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -msha512" } */ |
| 3 |
/* { dg-require-effective-target sha512 } */ |
| 4 |
|
| 5 |
#include "sha512-check.h" |
| 6 |
#include <emmintrin.h> |
| 7 |
#include <immintrin.h> |
| 8 |
|
| 9 |
static unsigned long long |
| 10 |
s0 (unsigned long long w) |
| 11 |
{ |
| 12 |
return ror64 (w, 1) ^ ror64 (w, 8) ^ shr64 (w, 7); |
| 13 |
} |
| 14 |
|
| 15 |
static void |
| 16 |
compute_sha512msg1(long long* src1, long long* src2, long long* res) |
| 17 |
{ |
| 18 |
unsigned long long w0, w1, w2, w3, w4; |
| 19 |
|
| 20 |
w0 = src1[0]; |
| 21 |
w1 = src1[1]; |
| 22 |
w2 = src1[2]; |
| 23 |
w3 = src1[3]; |
| 24 |
w4 = src2[0]; |
| 25 |
|
| 26 |
res[0] = w0 + s0 (w1); |
| 27 |
res[1] = w1 + s0 (w2); |
| 28 |
res[2] = w2 + s0 (w3); |
| 29 |
res[3] = w3 + s0 (w4); |
| 30 |
} |
| 31 |
|
| 32 |
static void |
| 33 |
sha512_test(void) |
| 34 |
{ |
| 35 |
union256i_q s1, res; |
| 36 |
union128i_q s2; |
| 37 |
long long res_ref[4]; |
| 38 |
|
| 39 |
s1.x = _mm256_set_epi64x (111, 222, 333, 444); |
| 40 |
s2.x = _mm_set_epi64x (0, 555); |
| 41 |
|
| 42 |
res.x = _mm256_sha512msg1_epi64 (s1.x, s2.x); |
| 43 |
|
| 44 |
compute_sha512msg1 (s1.a, s2.a, res_ref); |
| 45 |
|
| 46 |
if (check_union256i_q (res, res_ref)) |
| 47 |
abort(); |
| 48 |
} |