PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sha256msg1-2.c
blob2b70920b029797b3d74678f12b1c0ba923f24890
1 /* { dg-do run } */
2 /* { dg-options "-O2 -msha" } */
3 /* { dg-require-effective-target sha } */
5 #include "sha-check.h"
6 #include "m128-check.h"
7 #include <x86intrin.h>
8 #include <immintrin.h>
10 static int
11 s0 (int w)
13 return __rord (w, 7) ^ __rord (w, 18) ^ (w >> 3);
16 static void
17 compute_sha256msg1 (int *src1, int *src2, int *res)
19 int w0, w1, w2, w3, w4;
21 w0 = src1[0];
22 w1 = src1[1];
23 w2 = src1[2];
24 w3 = src1[3];
25 w4 = src2[0];
27 res[0] = w0 + s0 (w1);
28 res[1] = w1 + s0 (w2);
29 res[2] = w2 + s0 (w3);
30 res[3] = w3 + s0 (w4);
33 static void
34 sha_test (void)
36 union128i_d s1, s2, res;
37 int res_ref[4];
39 s1.x = _mm_set_epi32 (111, 222, 333, 444);
40 s2.x = _mm_set_epi32 (0, 0, 0, 555);
42 res.x = _mm_sha256msg1_epu32 (s1.x, s2.x);
44 compute_sha256msg1 (s1.a, s2.a, res_ref);
46 if (check_union128i_d (res, res_ref))
47 abort ();