Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gcc.target / i386 / aesenc.c
blobd2a8b60318800e9b64dd89e887e1116f1c0d57e7
1 /* { dg-do run } */
2 /* { dg-require-effective-target aes } */
3 /* { dg-options "-O2 -maes" } */
5 #ifndef CHECK_H
6 #define CHECK_H "aes-check.h"
7 #endif
9 #ifndef TEST
10 #define TEST aes_test
11 #endif
13 #include CHECK_H
15 #include <wmmintrin.h>
16 #include <string.h>
18 extern void abort (void);
20 #define NUM 1024
22 static __m128i src1[NUM];
23 static __m128i src2[NUM];
24 static __m128i edst[NUM];
26 static __m128i resdst[NUM];
28 /* Initialize input/output vectors. (Currently, there is only one set
29 of input/output vectors). */
31 static void
32 init_data (__m128i *s1, __m128i *s2, __m128i *d)
34 int i;
35 for (i = 0; i < NUM; i++)
37 s1[i] = _mm_setr_epi32 (0x5d53475d, 0x63746f72,
38 0x73745665, 0x7b5b5465);
39 s2[i] = _mm_setr_epi32 (0x726f6e5d, 0x5b477565,
40 0x68617929, 0x48692853);
41 d[i] = _mm_setr_epi32 (0xded7e595, 0x8b104b58,
42 0x9fdba3c5, 0xa8311c2f);
46 static void
47 TEST (void)
49 int i;
51 init_data (src1, src2, edst);
53 for (i = 0; i < NUM; i += 16)
55 resdst[i] = _mm_aesenc_si128 (src1[i], src2[i]);
56 resdst[i + 1] = _mm_aesenc_si128 (src1[i + 1], src2[i + 1]);
57 resdst[i + 2] = _mm_aesenc_si128 (src1[i + 2], src2[i + 2]);
58 resdst[i + 3] = _mm_aesenc_si128 (src1[i + 3], src2[i + 3]);
59 resdst[i + 4] = _mm_aesenc_si128 (src1[i + 4], src2[i + 4]);
60 resdst[i + 5] = _mm_aesenc_si128 (src1[i + 5], src2[i + 5]);
61 resdst[i + 6] = _mm_aesenc_si128 (src1[i + 6], src2[i + 6]);
62 resdst[i + 7] = _mm_aesenc_si128 (src1[i + 7], src2[i + 7]);
63 resdst[i + 8] = _mm_aesenc_si128 (src1[i + 8], src2[i + 8]);
64 resdst[i + 9] = _mm_aesenc_si128 (src1[i + 9], src2[i + 9]);
65 resdst[i + 10] = _mm_aesenc_si128 (src1[i + 10], src2[i + 10]);
66 resdst[i + 11] = _mm_aesenc_si128 (src1[i + 11], src2[i + 11]);
67 resdst[i + 12] = _mm_aesenc_si128 (src1[i + 12], src2[i + 12]);
68 resdst[i + 13] = _mm_aesenc_si128 (src1[i + 13], src2[i + 13]);
69 resdst[i + 14] = _mm_aesenc_si128 (src1[i + 14], src2[i + 14]);
70 resdst[i + 15] = _mm_aesenc_si128 (src1[i + 15], src2[i + 15]);
73 for (i = 0; i < NUM; i++)
74 if (memcmp (edst + i, resdst + i, sizeof (__m128i)))
75 abort ();