blob: 0ade413cb6ae0cbd25d989462a65b3deccf2d99b [file] [log] [blame]
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -07001// REQUIRES: powerpc-registered-target
2// RUN: %clang_cc1 -faltivec -triple powerpc64le-unknown-unknown \
3// RUN: -target-feature +crypto -target-feature +power8-vector \
4// RUN: -emit-llvm %s -o - | FileCheck %s
5
6// RUN: %clang_cc1 -faltivec -triple powerpc64-unknown-unknown \
7// RUN: -target-feature +crypto -target-feature +power8-vector \
8// RUN: -emit-llvm %s -o - | FileCheck %s
9
10// RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown \
11// RUN: -target-feature +crypto -target-feature +power8-vector \
12// RUN: -emit-llvm %s -o - | FileCheck %s
13#include <altivec.h>
14#define B_INIT1 { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, \
15 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10 };
16#define B_INIT2 { 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, \
17 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x70 };
18#define H_INIT1 { 0x0102, 0x0304, 0x0506, 0x0708, \
19 0x090A, 0x0B0C, 0x0D0E, 0x0F10 };
20#define H_INIT2 { 0x7172, 0x7374, 0x7576, 0x7778, \
21 0x797A, 0x7B7C, 0x7D7E, 0x7F70 };
22#define W_INIT1 { 0x01020304, 0x05060708, \
23 0x090A0B0C, 0x0D0E0F10 };
24#define W_INIT2 { 0x71727374, 0x75767778, \
25 0x797A7B7C, 0x7D7E7F70 };
26#define D_INIT1 { 0x0102030405060708, \
27 0x090A0B0C0D0E0F10 };
28#define D_INIT2 { 0x7172737475767778, \
29 0x797A7B7C7D7E7F70 };
30
31// CHECK-LABEL: define <16 x i8> @test_vpmsumb
32vector unsigned char test_vpmsumb(void)
33{
34 vector unsigned char a = B_INIT1
35 vector unsigned char b = B_INIT2
36 return __builtin_altivec_crypto_vpmsumb(a, b);
37// CHECK @llvm.ppc.altivec.crypto.vpmsumb
38}
39
40// CHECK-LABEL: define <8 x i16> @test_vpmsumh
41vector unsigned short test_vpmsumh(void)
42{
43 vector unsigned short a = H_INIT1
44 vector unsigned short b = H_INIT2
45 return __builtin_altivec_crypto_vpmsumh(a, b);
46// CHECK @llvm.ppc.altivec.crypto.vpmsumh
47}
48
49// CHECK-LABEL: define <4 x i32> @test_vpmsumw
50vector unsigned int test_vpmsumw(void)
51{
52 vector unsigned int a = W_INIT1
53 vector unsigned int b = W_INIT2
54 return __builtin_altivec_crypto_vpmsumw(a, b);
55// CHECK @llvm.ppc.altivec.crypto.vpmsumw
56}
57
58// CHECK-LABEL: define <2 x i64> @test_vpmsumd
59vector unsigned long long test_vpmsumd(void)
60{
61 vector unsigned long long a = D_INIT1
62 vector unsigned long long b = D_INIT2
63 return __builtin_altivec_crypto_vpmsumd(a, b);
64// CHECK @llvm.ppc.altivec.crypto.vpmsumd
65}
66
67// CHECK-LABEL: define <2 x i64> @test_vsbox
68vector unsigned long long test_vsbox(void)
69{
70 vector unsigned long long a = D_INIT1
71 return __builtin_altivec_crypto_vsbox(a);
72// CHECK: @llvm.ppc.altivec.crypto.vsbox
73}
74
75// CHECK-LABEL: define <16 x i8> @test_vpermxorb
76vector unsigned char test_vpermxorb(void)
77{
78 vector unsigned char a = B_INIT1
79 vector unsigned char b = B_INIT2
80 vector unsigned char c = B_INIT2
81 return __builtin_altivec_crypto_vpermxor(a, b, c);
82// CHECK: @llvm.ppc.altivec.crypto.vpermxor
83}
84
85// CHECK-LABEL: define <8 x i16> @test_vpermxorh
86vector unsigned short test_vpermxorh(void)
87{
88 vector unsigned short a = H_INIT1
89 vector unsigned short b = H_INIT2
90 vector unsigned short c = H_INIT2
91 return __builtin_altivec_crypto_vpermxor(a, b, c);
92// CHECK: @llvm.ppc.altivec.crypto.vpermxor
93}
94
95// CHECK-LABEL: define <4 x i32> @test_vpermxorw
96vector unsigned int test_vpermxorw(void)
97{
98 vector unsigned int a = W_INIT1
99 vector unsigned int b = W_INIT2
100 vector unsigned int c = W_INIT2
101 return __builtin_altivec_crypto_vpermxor(a, b, c);
102// CHECK: @llvm.ppc.altivec.crypto.vpermxor
103}
104
105// CHECK-LABEL: define <2 x i64> @test_vpermxord
106vector unsigned long long test_vpermxord(void)
107{
108 vector unsigned long long a = D_INIT1
109 vector unsigned long long b = D_INIT2
110 vector unsigned long long c = D_INIT2
111 return __builtin_altivec_crypto_vpermxor(a, b, c);
112// CHECK: @llvm.ppc.altivec.crypto.vpermxor
113}
114
115// CHECK-LABEL: define <2 x i64> @test_vcipher
116vector unsigned long long test_vcipher(void)
117{
118 vector unsigned long long a = D_INIT1
119 vector unsigned long long b = D_INIT2
120 return __builtin_altivec_crypto_vcipher(a, b);
121// CHECK: @llvm.ppc.altivec.crypto.vcipher
122}
123
124// CHECK-LABEL: define <2 x i64> @test_vcipherlast
125vector unsigned long long test_vcipherlast(void)
126{
127 vector unsigned long long a = D_INIT1
128 vector unsigned long long b = D_INIT2
129 return __builtin_altivec_crypto_vcipherlast(a, b);
130// CHECK: @llvm.ppc.altivec.crypto.vcipherlast
131}
132
133// CHECK: @llvm.ppc.altivec.crypto.vncipher
134vector unsigned long long test_vncipher(void)
135{
136 vector unsigned long long a = D_INIT1
137 vector unsigned long long b = D_INIT2
138 return __builtin_altivec_crypto_vncipher(a, b);
139// CHECK: @llvm.ppc.altivec.crypto.vncipher
140}
141
142// CHECK-LABEL: define <2 x i64> @test_vncipherlast
143vector unsigned long long test_vncipherlast(void)
144{
145 vector unsigned long long a = D_INIT1
146 vector unsigned long long b = D_INIT2
147 return __builtin_altivec_crypto_vncipherlast(a, b);
148// CHECK: @llvm.ppc.altivec.crypto.vncipherlast
149}
150
151// CHECK-LABEL: define <4 x i32> @test_vshasigmaw
152vector unsigned int test_vshasigmaw(void)
153{
154 vector unsigned int a = W_INIT1
155 return __builtin_altivec_crypto_vshasigmaw(a, 1, 15);
156// CHECK: @llvm.ppc.altivec.crypto.vshasigmaw
157}
158
159// CHECK-LABEL: define <2 x i64> @test_vshasigmad
160vector unsigned long long test_vshasigmad(void)
161{
162 vector unsigned long long a = D_INIT2
163 return __builtin_altivec_crypto_vshasigmad(a, 1, 15);
164// CHECK: @llvm.ppc.altivec.crypto.vshasigmad
165}
166
167// Test cases for the builtins the way they are exposed to
168// users through altivec.h
169// CHECK-LABEL: define <16 x i8> @test_vpmsumb_e
170vector unsigned char test_vpmsumb_e(void)
171{
172 vector unsigned char a = B_INIT1
173 vector unsigned char b = B_INIT2
174 return __builtin_crypto_vpmsumb(a, b);
175// CHECK @llvm.ppc.altivec.crypto.vpmsumb
176}
177
178// CHECK-LABEL: define <8 x i16> @test_vpmsumh_e
179vector unsigned short test_vpmsumh_e(void)
180{
181 vector unsigned short a = H_INIT1
182 vector unsigned short b = H_INIT2
183 return __builtin_crypto_vpmsumb(a, b);
184// CHECK @llvm.ppc.altivec.crypto.vpmsumh
185}
186
187// CHECK-LABEL: define <4 x i32> @test_vpmsumw_e
188vector unsigned int test_vpmsumw_e(void)
189{
190 vector unsigned int a = W_INIT1
191 vector unsigned int b = W_INIT2
192 return __builtin_crypto_vpmsumb(a, b);
193// CHECK @llvm.ppc.altivec.crypto.vpmsumw
194}
195
196// CHECK-LABEL: define <2 x i64> @test_vpmsumd_e
197vector unsigned long long test_vpmsumd_e(void)
198{
199 vector unsigned long long a = D_INIT1
200 vector unsigned long long b = D_INIT2
201 return __builtin_crypto_vpmsumb(a, b);
202// CHECK @llvm.ppc.altivec.crypto.vpmsumd
203}
204
205// CHECK-LABEL: define <2 x i64> @test_vsbox_e
206vector unsigned long long test_vsbox_e(void)
207{
208 vector unsigned long long a = D_INIT1
209 return __builtin_crypto_vsbox(a);
210// CHECK: @llvm.ppc.altivec.crypto.vsbox
211}
212
213// CHECK-LABEL: define <16 x i8> @test_vpermxorb_e
214vector unsigned char test_vpermxorb_e(void)
215{
216 vector unsigned char a = B_INIT1
217 vector unsigned char b = B_INIT2
218 vector unsigned char c = B_INIT2
219 return __builtin_crypto_vpermxor(a, b, c);
220// CHECK: @llvm.ppc.altivec.crypto.vpermxor
221}
222
223// CHECK-LABEL: define <8 x i16> @test_vpermxorh_e
224vector unsigned short test_vpermxorh_e(void)
225{
226 vector unsigned short a = H_INIT1
227 vector unsigned short b = H_INIT2
228 vector unsigned short c = H_INIT2
229 return __builtin_crypto_vpermxor(a, b, c);
230}
231
232// CHECK-LABEL: define <4 x i32> @test_vpermxorw_e
233vector unsigned int test_vpermxorw_e(void)
234{
235 vector unsigned int a = W_INIT1
236 vector unsigned int b = W_INIT2
237 vector unsigned int c = W_INIT2
238 return __builtin_crypto_vpermxor(a, b, c);
239// CHECK: @llvm.ppc.altivec.crypto.vpermxor
240}
241
242// CHECK-LABEL: define <2 x i64> @test_vpermxord_e
243vector unsigned long long test_vpermxord_e(void)
244{
245 vector unsigned long long a = D_INIT1
246 vector unsigned long long b = D_INIT2
247 vector unsigned long long c = D_INIT2
248 return __builtin_crypto_vpermxor(a, b, c);
249// CHECK: @llvm.ppc.altivec.crypto.vpermxor
250}
251
252// CHECK-LABEL: define <2 x i64> @test_vcipher_e
253vector unsigned long long test_vcipher_e(void)
254{
255 vector unsigned long long a = D_INIT1
256 vector unsigned long long b = D_INIT2
257 return __builtin_crypto_vcipher(a, b);
258// CHECK: @llvm.ppc.altivec.crypto.vcipher
259}
260
261// CHECK-LABEL: define <2 x i64> @test_vcipherlast_e
262vector unsigned long long test_vcipherlast_e(void)
263{
264 vector unsigned long long a = D_INIT1
265 vector unsigned long long b = D_INIT2
266 return __builtin_crypto_vcipherlast(a, b);
267// CHECK: @llvm.ppc.altivec.crypto.vcipherlast
268}
269
270// CHECK-LABEL: define <2 x i64> @test_vncipher_e
271vector unsigned long long test_vncipher_e(void)
272{
273 vector unsigned long long a = D_INIT1
274 vector unsigned long long b = D_INIT2
275 return __builtin_crypto_vncipher(a, b);
276// CHECK: @llvm.ppc.altivec.crypto.vncipher
277}
278
279// CHECK-LABEL: define <2 x i64> @test_vncipherlast_e
280vector unsigned long long test_vncipherlast_e(void)
281{
282 vector unsigned long long a = D_INIT1
283 vector unsigned long long b = D_INIT2
284 return __builtin_crypto_vncipherlast(a, b);
285// CHECK: @llvm.ppc.altivec.crypto.vncipherlast
286}
287
288// CHECK-LABEL: define <4 x i32> @test_vshasigmaw_e
289vector unsigned int test_vshasigmaw_e(void)
290{
291 vector unsigned int a = W_INIT1
292 return __builtin_crypto_vshasigmaw(a, 1, 15);
293// CHECK: @llvm.ppc.altivec.crypto.vshasigmaw
294}
295
296// CHECK-LABEL: define <2 x i64> @test_vshasigmad_e
297vector unsigned long long test_vshasigmad_e(void)
298{
299 vector unsigned long long a = D_INIT2
300 return __builtin_crypto_vshasigmad(a, 0, 15);
301// CHECK: @llvm.ppc.altivec.crypto.vshasigmad
302}
303