| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -msha" } */ |
| 3 |
/* { dg-require-effective-target sha } */ |
| 4 |
|
| 5 |
#include "sha-check.h" |
| 6 |
#include "m128-check.h" |
| 7 |
#include <x86intrin.h> |
| 8 |
#include <immintrin.h> |
| 9 |
|
| 10 |
static int |
| 11 |
s0 (int w) |
| 12 |
{ |
| 13 |
return __rord (w, 7) ^ __rord (w, 18) ^ (w >> 3); |
| 14 |
} |
| 15 |
|
| 16 |
static void |
| 17 |
compute_sha256msg1 (int *src1, int *src2, int *res) |
| 18 |
{ |
| 19 |
int w0, w1, w2, w3, w4; |
| 20 |
|
| 21 |
w0 = src1[0]; |
| 22 |
w1 = src1[1]; |
| 23 |
w2 = src1[2]; |
| 24 |
w3 = src1[3]; |
| 25 |
w4 = src2[0]; |
| 26 |
|
| 27 |
res[0] = w0 + s0 (w1); |
| 28 |
res[1] = w1 + s0 (w2); |
| 29 |
res[2] = w2 + s0 (w3); |
| 30 |
res[3] = w3 + s0 (w4); |
| 31 |
} |
| 32 |
|
| 33 |
static void |
| 34 |
sha_test (void) |
| 35 |
{ |
| 36 |
union128i_d s1, s2, res; |
| 37 |
int res_ref[4]; |
| 38 |
|
| 39 |
s1.x = _mm_set_epi32 (111, 222, 333, 444); |
| 40 |
s2.x = _mm_set_epi32 (0, 0, 0, 555); |
| 41 |
|
| 42 |
res.x = _mm_sha256msg1_epu32 (s1.x, s2.x); |
| 43 |
|
| 44 |
compute_sha256msg1 (s1.a, s2.a, res_ref); |
| 45 |
|
| 46 |
if (check_union128i_d (res, res_ref)) |
| 47 |
abort (); |
| 48 |
} |