1 /* { dg-do run } */
2 /* { dg-require-effective-target pclmul } */
3 /* { dg-options "-O2 -mpclmul" } */
4
5 #ifndef CHECK_H
6 #define CHECK_H "pclmul-check.h"
7 #endif
8
9 #ifndef TEST
10 #define TEST pclmul_test
11 #endif
12
13 #include CHECK_H
14
15 #include <wmmintrin.h>
16 #include <string.h>
17
18 extern void abort (void);
19
20 #define NUM 1024
21
22 static __m128i s1[NUM];
23 static __m128i s2[NUM];
24 /* We need this array to generate mem form of inst */
25 static __m128i s2m[NUM];
26
27 static __m128i e_00[NUM];
28 static __m128i e_01[NUM];
29 static __m128i e_10[NUM];
30 static __m128i e_11[NUM];
31
32 static __m128i d_00[NUM];
33 static __m128i d_01[NUM];
34 static __m128i d_10[NUM];
35 static __m128i d_11[NUM];
36
37 /* Initialize input/output vectors. (Currently, there is only one set
38 of input/output vectors). */
39 static void
init_data(__m128i * ls1,__m128i * ls2,__m128i * le_00,__m128i * le_01,__m128i * le_10,__m128i * le_11)40 init_data (__m128i *ls1, __m128i *ls2, __m128i *le_00, __m128i *le_01,
41 __m128i *le_10, __m128i *le_11)
42 {
43 int i;
44
45 for (i = 0; i < NUM; i++)
46 {
47 ls1[i] = _mm_set_epi32 (0x7B5B5465, 0x73745665,
48 0x63746F72, 0x5D53475D);
49 ls2[i] = _mm_set_epi32 (0x48692853, 0x68617929,
50 0x5B477565, 0x726F6E5D);
51 s2m[i] = _mm_set_epi32 (0x48692853, 0x68617929,
52 0x5B477565, 0x726F6E5D);
53 le_00[i] = _mm_set_epi32 (0x1D4D84C8, 0x5C3440C0,
54 0x929633D5, 0xD36F0451);
55 le_01[i] = _mm_set_epi32 (0x1A2BF6DB, 0x3A30862F,
56 0xBABF262D, 0xF4B7D5C9);
57 le_10[i] = _mm_set_epi32 (0x1BD17C8D, 0x556AB5A1,
58 0x7FA540AC, 0x2A281315);
59 le_11[i] = _mm_set_epi32 (0x1D1E1F2C, 0x592E7C45,
60 0xD66EE03E, 0x410FD4ED);
61 }
62 }
63
64 static void
TEST(void)65 TEST (void)
66 {
67 int i;
68
69 init_data (s1, s2, e_00, e_01, e_10, e_11);
70
71 for (i = 0; i < NUM; i += 2)
72 {
73 d_00[i] = _mm_clmulepi64_si128 (s1[i], s2m[i], 0x00);
74 d_01[i] = _mm_clmulepi64_si128 (s1[i], s2[i], 0x01);
75 d_10[i] = _mm_clmulepi64_si128 (s1[i], s2[i], 0x10);
76 d_11[i] = _mm_clmulepi64_si128 (s1[i], s2[i], 0x11);
77
78 d_11[i + 1] = _mm_clmulepi64_si128 (s1[i + 1], s2[i + 1], 0x11);
79 d_00[i + 1] = _mm_clmulepi64_si128 (s1[i + 1], s2[i + 1], 0x00);
80 d_10[i + 1] = _mm_clmulepi64_si128 (s1[i + 1], s2m[i + 1], 0x10);
81 d_01[i + 1] = _mm_clmulepi64_si128 (s1[i + 1], s2[i + 1], 0x01);
82 }
83
84 for (i = 0; i < NUM; i++)
85 {
86 if (memcmp (d_00 + i, e_00 + i, sizeof (__m128i)))
87 abort ();
88 if (memcmp (d_01 + i, e_01 + i, sizeof (__m128i)))
89 abort ();
90 if (memcmp (d_10 + i, e_10 + i, sizeof (__m128i)))
91 abort ();
92 if (memcmp(d_11 + i, e_11 + i, sizeof (__m128i)))
93 abort ();
94 }
95 }
96