1260401Sscottl/* { dg-do run } */
2260401Sscottl/* { dg-require-effective-target aes } */
3260401Sscottl/* { dg-options "-O2 -maes" } */
4260401Sscottl
5260401Sscottl#ifndef CHECK_H
6260401Sscottl#define CHECK_H "aes-check.h"
7260401Sscottl#endif
8260401Sscottl
9260401Sscottl#ifndef TEST
10260401Sscottl#define TEST aes_test
11260401Sscottl#endif
12260401Sscottl
13260401Sscottl#include CHECK_H
14260401Sscottl
15260401Sscottl#include <wmmintrin.h>
16260401Sscottl#include <string.h>
17260401Sscottl
18260401Sscottlextern void abort (void);
19260401Sscottl
20260401Sscottl#define NUM 1024
21260401Sscottl
22260401Sscottlstatic __m128i src1[NUM];
23260401Sscottlstatic __m128i src2[NUM];
24260401Sscottlstatic __m128i edst[NUM];
25260401Sscottl
26260401Sscottlstatic __m128i resdst[NUM];
27260401Sscottl
28260401Sscottl/* Initialize input/output vectors.  (Currently, there is only one set
29260401Sscottl   of input/output vectors).  */
30260401Sscottl
31260401Sscottlstatic void
32260401Sscottlinit_data (__m128i *s1, __m128i *s2, __m128i *d)
33260401Sscottl{
34260401Sscottl  int i;
35260401Sscottl  for (i = 0; i < NUM; i++)
36260401Sscottl    {
37260401Sscottl      s1[i] = _mm_setr_epi32 (0x5d53475d, 0x63746f72,
38260401Sscottl			      0x73745665, 0x7b5b5465);
39260401Sscottl      s2[i] = _mm_setr_epi32 (0x726f6e5d, 0x5b477565,
40260401Sscottl			      0x68617929, 0x48692853);
41260401Sscottl      d[i] = _mm_setr_epi32 (0xded7e595, 0x8b104b58,
42260401Sscottl			     0x9fdba3c5, 0xa8311c2f);
43260401Sscottl    }
44260401Sscottl}
45260401Sscottl
46260401Sscottlstatic void
47260401SscottlTEST (void)
48260401Sscottl{
49260401Sscottl  int i;
50260401Sscottl
51260401Sscottl  init_data (src1, src2, edst);
52260401Sscottl
53260401Sscottl  for (i = 0; i < NUM; i += 16)
54260401Sscottl    {
55260401Sscottl      resdst[i] = _mm_aesenc_si128 (src1[i], src2[i]);
56260401Sscottl      resdst[i + 1] = _mm_aesenc_si128 (src1[i + 1], src2[i + 1]);
57260401Sscottl      resdst[i + 2] = _mm_aesenc_si128 (src1[i + 2], src2[i + 2]);
58260401Sscottl      resdst[i + 3] = _mm_aesenc_si128 (src1[i + 3], src2[i + 3]);
59260401Sscottl      resdst[i + 4] = _mm_aesenc_si128 (src1[i + 4], src2[i + 4]);
60260401Sscottl      resdst[i + 5] = _mm_aesenc_si128 (src1[i + 5], src2[i + 5]);
61260401Sscottl      resdst[i + 6] = _mm_aesenc_si128 (src1[i + 6], src2[i + 6]);
62260401Sscottl      resdst[i + 7] = _mm_aesenc_si128 (src1[i + 7], src2[i + 7]);
63260401Sscottl      resdst[i + 8] = _mm_aesenc_si128 (src1[i + 8], src2[i + 8]);
64260401Sscottl      resdst[i + 9] = _mm_aesenc_si128 (src1[i + 9], src2[i + 9]);
65260401Sscottl      resdst[i + 10] = _mm_aesenc_si128 (src1[i + 10], src2[i + 10]);
66260401Sscottl      resdst[i + 11] = _mm_aesenc_si128 (src1[i + 11], src2[i + 11]);
67260401Sscottl      resdst[i + 12] = _mm_aesenc_si128 (src1[i + 12], src2[i + 12]);
68260401Sscottl      resdst[i + 13] = _mm_aesenc_si128 (src1[i + 13], src2[i + 13]);
69260401Sscottl      resdst[i + 14] = _mm_aesenc_si128 (src1[i + 14], src2[i + 14]);
70260401Sscottl      resdst[i + 15] = _mm_aesenc_si128 (src1[i + 15], src2[i + 15]);
71260401Sscottl    }
72260401Sscottl
73260401Sscottl  for (i = 0; i < NUM; i++)
74260401Sscottl    if (memcmp (edst + i, resdst + i, sizeof (__m128i)))
75260401Sscottl      abort ();
76260401Sscottl}
77260401Sscottl