Debian Codegraph @

gcc/testsuite/gcc.target/i386/sha512msg2-2.c

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