1 // 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
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
10 #define B_INIT1 { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, \
11 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10 };
12 #define B_INIT2 { 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, \
13 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x70 };
14 #define H_INIT1 { 0x0102, 0x0304, 0x0506, 0x0708, \
15 0x090A, 0x0B0C, 0x0D0E, 0x0F10 };
16 #define H_INIT2 { 0x7172, 0x7374, 0x7576, 0x7778, \
17 0x797A, 0x7B7C, 0x7D7E, 0x7F70 };
18 #define W_INIT1 { 0x01020304, 0x05060708, \
19 0x090A0B0C, 0x0D0E0F10 };
20 #define W_INIT2 { 0x71727374, 0x75767778, \
21 0x797A7B7C, 0x7D7E7F70 };
22 #define D_INIT1 { 0x0102030405060708, \
24 #define D_INIT2 { 0x7172737475767778, \
27 // CHECK-LABEL: define <16 x i8> @test_vpmsumb
28 vector unsigned char test_vpmsumb(void)
30 vector unsigned char a = B_INIT1
31 vector unsigned char b = B_INIT2
32 return __builtin_altivec_crypto_vpmsumb(a, b);
33 // CHECK: @llvm.ppc.altivec.crypto.vpmsumb
36 // CHECK-LABEL: define <8 x i16> @test_vpmsumh
37 vector unsigned short test_vpmsumh(void)
39 vector unsigned short a = H_INIT1
40 vector unsigned short b = H_INIT2
41 return __builtin_altivec_crypto_vpmsumh(a, b);
42 // CHECK: @llvm.ppc.altivec.crypto.vpmsumh
45 // CHECK-LABEL: define <4 x i32> @test_vpmsumw
46 vector unsigned int test_vpmsumw(void)
48 vector unsigned int a = W_INIT1
49 vector unsigned int b = W_INIT2
50 return __builtin_altivec_crypto_vpmsumw(a, b);
51 // CHECK: @llvm.ppc.altivec.crypto.vpmsumw
54 // CHECK-LABEL: define <2 x i64> @test_vpmsumd
55 vector unsigned long long test_vpmsumd(void)
57 vector unsigned long long a = D_INIT1
58 vector unsigned long long b = D_INIT2
59 return __builtin_altivec_crypto_vpmsumd(a, b);
60 // CHECK: @llvm.ppc.altivec.crypto.vpmsumd
63 // CHECK-LABEL: define <2 x i64> @test_vsbox
64 vector unsigned long long test_vsbox(void)
66 vector unsigned long long a = D_INIT1
67 return __builtin_altivec_crypto_vsbox(a);
68 // CHECK: @llvm.ppc.altivec.crypto.vsbox
71 // CHECK-LABEL: define <16 x i8> @test_vpermxorb
72 vector unsigned char test_vpermxorb(void)
74 vector unsigned char a = B_INIT1
75 vector unsigned char b = B_INIT2
76 vector unsigned char c = B_INIT2
77 return __builtin_altivec_crypto_vpermxor(a, b, c);
78 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
81 // CHECK-LABEL: define <8 x i16> @test_vpermxorh
82 vector unsigned short test_vpermxorh(void)
84 vector unsigned short a = H_INIT1
85 vector unsigned short b = H_INIT2
86 vector unsigned short c = H_INIT2
87 return __builtin_altivec_crypto_vpermxor(a, b, c);
88 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
91 // CHECK-LABEL: define <4 x i32> @test_vpermxorw
92 vector unsigned int test_vpermxorw(void)
94 vector unsigned int a = W_INIT1
95 vector unsigned int b = W_INIT2
96 vector unsigned int c = W_INIT2
97 return __builtin_altivec_crypto_vpermxor(a, b, c);
98 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
101 // CHECK-LABEL: define <2 x i64> @test_vpermxord
102 vector unsigned long long test_vpermxord(void)
104 vector unsigned long long a = D_INIT1
105 vector unsigned long long b = D_INIT2
106 vector unsigned long long c = D_INIT2
107 return __builtin_altivec_crypto_vpermxor(a, b, c);
108 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
111 // CHECK-LABEL: test_vpermxorbc
112 vector bool char test_vpermxorbc(vector bool char a,
114 vector bool char c) {
115 return vec_permxor(a, b, c);
116 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
119 // CHECK-LABEL: test_vpermxorsc
120 vector signed char test_vpermxorsc(vector signed char a,
121 vector signed char b,
122 vector signed char c) {
123 return vec_permxor(a, b, c);
124 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
127 // CHECK-LABEL: test_vpermxoruc
128 vector unsigned char test_vpermxoruc(vector unsigned char a,
129 vector unsigned char b,
130 vector unsigned char c) {
131 return vec_permxor(a, b, c);
132 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
135 // CHECK-LABEL: define <2 x i64> @test_vcipher
136 vector unsigned long long test_vcipher(void)
138 vector unsigned long long a = D_INIT1
139 vector unsigned long long b = D_INIT2
140 return __builtin_altivec_crypto_vcipher(a, b);
141 // CHECK: @llvm.ppc.altivec.crypto.vcipher
144 // CHECK-LABEL: define <2 x i64> @test_vcipherlast
145 vector unsigned long long test_vcipherlast(void)
147 vector unsigned long long a = D_INIT1
148 vector unsigned long long b = D_INIT2
149 return __builtin_altivec_crypto_vcipherlast(a, b);
150 // CHECK: @llvm.ppc.altivec.crypto.vcipherlast
153 // CHECK-LABEL: @test_vncipher
154 vector unsigned long long test_vncipher(void)
156 vector unsigned long long a = D_INIT1
157 vector unsigned long long b = D_INIT2
158 return __builtin_altivec_crypto_vncipher(a, b);
159 // CHECK: @llvm.ppc.altivec.crypto.vncipher
162 // CHECK-LABEL: define <2 x i64> @test_vncipherlast
163 vector unsigned long long test_vncipherlast(void)
165 vector unsigned long long a = D_INIT1
166 vector unsigned long long b = D_INIT2
167 return __builtin_altivec_crypto_vncipherlast(a, b);
168 // CHECK: @llvm.ppc.altivec.crypto.vncipherlast
171 // CHECK-LABEL: define <4 x i32> @test_vshasigmaw
172 vector unsigned int test_vshasigmaw(void)
174 vector unsigned int a = W_INIT1
175 return __builtin_altivec_crypto_vshasigmaw(a, 1, 15);
176 // CHECK: @llvm.ppc.altivec.crypto.vshasigmaw
179 // CHECK-LABEL: define <2 x i64> @test_vshasigmad
180 vector unsigned long long test_vshasigmad(void)
182 vector unsigned long long a = D_INIT2
183 return __builtin_altivec_crypto_vshasigmad(a, 1, 15);
184 // CHECK: @llvm.ppc.altivec.crypto.vshasigmad
187 // Test cases for the builtins the way they are exposed to
188 // users through altivec.h
189 // CHECK-LABEL: define <16 x i8> @test_vpmsumb_e
190 vector unsigned char test_vpmsumb_e(void)
192 vector unsigned char a = B_INIT1
193 vector unsigned char b = B_INIT2
194 return __builtin_crypto_vpmsumb(a, b);
195 // CHECK: @llvm.ppc.altivec.crypto.vpmsumb
198 // CHECK-LABEL: define <8 x i16> @test_vpmsumh_e
199 vector unsigned short test_vpmsumh_e(void)
201 vector unsigned short a = H_INIT1
202 vector unsigned short b = H_INIT2
203 return __builtin_crypto_vpmsumb(a, b);
204 // CHECK: @llvm.ppc.altivec.crypto.vpmsumh
207 // CHECK-LABEL: define <4 x i32> @test_vpmsumw_e
208 vector unsigned int test_vpmsumw_e(void)
210 vector unsigned int a = W_INIT1
211 vector unsigned int b = W_INIT2
212 return __builtin_crypto_vpmsumb(a, b);
213 // CHECK: @llvm.ppc.altivec.crypto.vpmsumw
216 // CHECK-LABEL: define <2 x i64> @test_vpmsumd_e
217 vector unsigned long long test_vpmsumd_e(void)
219 vector unsigned long long a = D_INIT1
220 vector unsigned long long b = D_INIT2
221 return __builtin_crypto_vpmsumb(a, b);
222 // CHECK: @llvm.ppc.altivec.crypto.vpmsumd
225 // CHECK-LABEL: define <2 x i64> @test_vsbox_e
226 vector unsigned long long test_vsbox_e(void)
228 vector unsigned long long a = D_INIT1
229 return __builtin_crypto_vsbox(a);
230 // CHECK: @llvm.ppc.altivec.crypto.vsbox
233 // CHECK-LABEL: define <16 x i8> @test_vpermxorb_e
234 vector unsigned char test_vpermxorb_e(void)
236 vector unsigned char a = B_INIT1
237 vector unsigned char b = B_INIT2
238 vector unsigned char c = B_INIT2
239 return __builtin_crypto_vpermxor(a, b, c);
240 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
243 // CHECK-LABEL: define <8 x i16> @test_vpermxorh_e
244 vector unsigned short test_vpermxorh_e(void)
246 vector unsigned short a = H_INIT1
247 vector unsigned short b = H_INIT2
248 vector unsigned short c = H_INIT2
249 return __builtin_crypto_vpermxor(a, b, c);
250 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
253 // CHECK-LABEL: define <4 x i32> @test_vpermxorw_e
254 vector unsigned int test_vpermxorw_e(void)
256 vector unsigned int a = W_INIT1
257 vector unsigned int b = W_INIT2
258 vector unsigned int c = W_INIT2
259 return __builtin_crypto_vpermxor(a, b, c);
260 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
263 // CHECK-LABEL: define <2 x i64> @test_vpermxord_e
264 vector unsigned long long test_vpermxord_e(void)
266 vector unsigned long long a = D_INIT1
267 vector unsigned long long b = D_INIT2
268 vector unsigned long long c = D_INIT2
269 return __builtin_crypto_vpermxor(a, b, c);
270 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
273 // CHECK-LABEL: define <2 x i64> @test_vcipher_e
274 vector unsigned long long test_vcipher_e(void)
276 vector unsigned long long a = D_INIT1
277 vector unsigned long long b = D_INIT2
278 return __builtin_crypto_vcipher(a, b);
279 // CHECK: @llvm.ppc.altivec.crypto.vcipher
282 // CHECK-LABEL: define <2 x i64> @test_vcipherlast_e
283 vector unsigned long long test_vcipherlast_e(void)
285 vector unsigned long long a = D_INIT1
286 vector unsigned long long b = D_INIT2
287 return __builtin_crypto_vcipherlast(a, b);
288 // CHECK: @llvm.ppc.altivec.crypto.vcipherlast
291 // CHECK-LABEL: define <2 x i64> @test_vncipher_e
292 vector unsigned long long test_vncipher_e(void)
294 vector unsigned long long a = D_INIT1
295 vector unsigned long long b = D_INIT2
296 return __builtin_crypto_vncipher(a, b);
297 // CHECK: @llvm.ppc.altivec.crypto.vncipher
300 // CHECK-LABEL: define <2 x i64> @test_vncipherlast_e
301 vector unsigned long long test_vncipherlast_e(void)
303 vector unsigned long long a = D_INIT1
304 vector unsigned long long b = D_INIT2
305 return __builtin_crypto_vncipherlast(a, b);
306 // CHECK: @llvm.ppc.altivec.crypto.vncipherlast
309 // CHECK-LABEL: define <4 x i32> @test_vshasigmaw_e
310 vector unsigned int test_vshasigmaw_e(void)
312 vector unsigned int a = W_INIT1
313 return __builtin_crypto_vshasigmaw(a, 1, 15);
314 // CHECK: @llvm.ppc.altivec.crypto.vshasigmaw
317 // CHECK-LABEL: define <2 x i64> @test_vshasigmad_e
318 vector unsigned long long test_vshasigmad_e(void)
320 vector unsigned long long a = D_INIT2
321 return __builtin_crypto_vshasigmad(a, 0, 15);
322 // CHECK: @llvm.ppc.altivec.crypto.vshasigmad
325 // CHECK-LABEL: @test_vec_sbox_be
326 vector unsigned char test_vec_sbox_be(void)
328 vector unsigned char a = B_INIT1
329 return vec_sbox_be(a);
330 // CHECK: @llvm.ppc.altivec.crypto.vsbox
333 // CHECK-LABEL: @test_vec_cipher_be
334 vector unsigned char test_vec_cipher_be(void)
336 vector unsigned char a = B_INIT1
337 vector unsigned char b = B_INIT2
338 return vec_cipher_be(a, b);
339 // CHECK: @llvm.ppc.altivec.crypto.vcipher
342 // CHECK-LABEL: @test_vec_cipherlast_be
343 vector unsigned char test_vec_cipherlast_be(void)
345 vector unsigned char a = B_INIT1
346 vector unsigned char b = B_INIT2
347 return vec_cipherlast_be(a, b);
348 // CHECK: @llvm.ppc.altivec.crypto.vcipherlast
351 // CHECK-LABEL: @test_vec_ncipher_be
352 vector unsigned char test_vec_ncipher_be(void)
354 vector unsigned char a = B_INIT1
355 vector unsigned char b = B_INIT2
356 return vec_ncipher_be(a, b);
357 // CHECK: @llvm.ppc.altivec.crypto.vncipher
360 // CHECK-LABEL: @test_vec_ncipherlast_be
361 vector unsigned char test_vec_ncipherlast_be(void)
363 vector unsigned char a = B_INIT1
364 vector unsigned char b = B_INIT2
365 return vec_ncipherlast_be(a, b);
366 // CHECK: @llvm.ppc.altivec.crypto.vncipherlast
369 // CHECK-LABEL: @test_vec_shasigma_bew
370 vector unsigned int test_vec_shasigma_bew(void)
372 vector unsigned int a = W_INIT1
373 return vec_shasigma_be(a, 1, 15);
374 // CHECK: @llvm.ppc.altivec.crypto.vshasigmaw
377 // CHECK-LABEL: @test_vec_shasigma_bed
378 vector unsigned long long test_vec_shasigma_bed(void)
380 vector unsigned long long a = D_INIT2
381 return vec_shasigma_be(a, 1, 15);
382 // CHECK: @llvm.ppc.altivec.crypto.vshasigmad
385 // CHECK-LABEL: @test_vec_pmsum_beb
386 vector unsigned short test_vec_pmsum_beb(void)
388 vector unsigned char a = B_INIT1
389 vector unsigned char b = B_INIT2
390 return vec_pmsum_be(a, b);
391 // CHECK: @llvm.ppc.altivec.crypto.vpmsumb
394 // CHECK-LABEL: @test_vec_pmsum_beh
395 vector unsigned int test_vec_pmsum_beh(void)
397 vector unsigned short a = H_INIT1
398 vector unsigned short b = H_INIT2
399 return vec_pmsum_be(a, b);
400 // CHECK: @llvm.ppc.altivec.crypto.vpmsumh
403 // CHECK-LABEL: @test_vec_pmsum_bew
404 vector unsigned long long test_vec_pmsum_bew(void)
406 vector unsigned int a = W_INIT1
407 vector unsigned int b = W_INIT2
408 return vec_pmsum_be(a, b);
409 // CHECK: @llvm.ppc.altivec.crypto.vpmsumw
412 // CHECK-LABEL: @test_vec_pmsum_bed
413 vector unsigned __int128 test_vec_pmsum_bed(void)
415 vector unsigned long long a = D_INIT1
416 vector unsigned long long b = D_INIT2
417 return vec_pmsum_be(a, b);
418 // CHECK: @llvm.ppc.altivec.crypto.vpmsumd