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 <immintrin.h>
8 
9 static void
compute_sha1msg1(int * s1,int * s2,int * r)10 compute_sha1msg1 (int *s1, int *s2, int *r)
11 {
12   int w0, w1, w2, w3, w4, w5;
13 
14   w0 = s1[3];
15   w1 = s1[2];
16   w2 = s1[1];
17   w3 = s1[0];
18   w4 = s2[3];
19   w5 = s2[2];
20 
21   r[0] = w5 ^ w3;
22   r[1] = w4 ^ w2;
23   r[2] = w3 ^ w1;
24   r[3] = w2 ^ w0;
25 }
26 
27 static void
sha_test(void)28 sha_test (void)
29 {
30   union128i_d s1, s2, res;
31   int res_ref[4];
32 
33   s1.x = _mm_set_epi32 (111, 222, 333, 444);
34   s2.x = _mm_set_epi32 (555, 666, 0, 0);
35 
36   res.x = _mm_sha1msg1_epu32 (s1.x, s2.x);
37 
38   compute_sha1msg1 (s1.a, s2.a, res_ref);
39 
40   if (check_union128i_d (res, res_ref))
41     abort ();
42 }
43