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
10static void
11compute_sha1msg2 (int *s1, int *s2, int *r)
12{
13  int w13, w14, w15, w16, w17, w18, w19;
14
15  w13 = s2[2];
16  w14 = s2[1];
17  w15 = s2[0];
18  w16 = __rold (s1[3] ^ w13, 1);
19  w17 = __rold (s1[2] ^ w14, 1);
20  w18 = __rold (s1[1] ^ w15, 1);
21  w19 = __rold (s1[0] ^ w16, 1);
22
23  r[0] = w19;
24  r[1] = w18;
25  r[2] = w17;
26  r[3] = w16;
27}
28
29static void
30sha_test (void)
31{
32  union128i_d s1, s2, res;
33  int res_ref[4];
34
35  s1.x = _mm_set_epi32 (111, 222, 333, 444);
36  s2.x = _mm_set_epi32 (555, 666, 777, 0);
37
38  res.x = _mm_sha1msg2_epu32 (s1.x, s2.x);
39
40  compute_sha1msg2 (s1.a, s2.a, res_ref);
41
42  if (check_union128i_d (res, res_ref))
43    abort ();
44}
45