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
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
test_vpmsumb(void)32 vector 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
test_vpmsumh(void)41 vector 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
test_vpmsumw(void)50 vector 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
test_vpmsumd(void)59 vector 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
test_vsbox(void)68 vector 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
test_vpermxorb(void)76 vector 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
test_vpermxorh(void)86 vector 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
test_vpermxorw(void)96 vector 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
test_vpermxord(void)106 vector 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
test_vcipher(void)116 vector 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
test_vcipherlast(void)125 vector 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
test_vncipher(void)134 vector 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
test_vncipherlast(void)143 vector 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
test_vshasigmaw(void)152 vector 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
test_vshasigmad(void)160 vector 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
test_vpmsumb_e(void)170 vector 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
test_vpmsumh_e(void)179 vector 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
test_vpmsumw_e(void)188 vector 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
test_vpmsumd_e(void)197 vector 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
test_vsbox_e(void)206 vector 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
test_vpermxorb_e(void)214 vector 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
test_vpermxorh_e(void)224 vector 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
test_vpermxorw_e(void)233 vector 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
test_vpermxord_e(void)243 vector 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
test_vcipher_e(void)253 vector 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
test_vcipherlast_e(void)262 vector 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
test_vncipher_e(void)271 vector 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
test_vncipherlast_e(void)280 vector 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
test_vshasigmaw_e(void)289 vector 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
test_vshasigmad_e(void)297 vector 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
304