1 // REQUIRES: powerpc-registered-target 2 // RUN: %clang_cc1 -target-feature +altivec -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 -target-feature +altivec -triple powerpc64-unknown-unknown \ 7 // RUN: -target-feature +crypto -target-feature +power8-vector \ 8 // RUN: -emit-llvm %s -o - | FileCheck %s 9 #include <altivec.h> 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, \ 23 0x090A0B0C0D0E0F10 }; 24 #define D_INIT2 { 0x7172737475767778, \ 25 0x797A7B7C7D7E7F70 }; 26 27 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vpmsumb 28 vector unsigned char test_vpmsumb(void) 29 { 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 34 } 35 36 // CHECK-LABEL: define{{.*}} <8 x i16> @test_vpmsumh 37 vector unsigned short test_vpmsumh(void) 38 { 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 43 } 44 45 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vpmsumw 46 vector unsigned int test_vpmsumw(void) 47 { 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 52 } 53 54 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vpmsumd 55 vector unsigned long long test_vpmsumd(void) 56 { 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 61 } 62 63 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vsbox 64 vector unsigned long long test_vsbox(void) 65 { 66 vector unsigned long long a = D_INIT1 67 return __builtin_altivec_crypto_vsbox(a); 68 // CHECK: @llvm.ppc.altivec.crypto.vsbox 69 } 70 71 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxorb 72 vector unsigned char test_vpermxorb(void) 73 { 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 79 } 80 81 // CHECK-LABEL: define{{.*}} <8 x i16> @test_vpermxorh 82 vector unsigned short test_vpermxorh(void) 83 { 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 89 } 90 91 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vpermxorw 92 vector unsigned int test_vpermxorw(void) 93 { 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 99 } 100 101 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vpermxord 102 vector unsigned long long test_vpermxord(void) 103 { 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 109 } 110 111 // CHECK-LABEL: test_vpermxorbc 112 vector bool char test_vpermxorbc(vector bool char a, 113 vector bool char b, 114 vector bool char c) { 115 return vec_permxor(a, b, c); 116 // CHECK: @llvm.ppc.altivec.crypto.vpermxor 117 } 118 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 125 } 126 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 133 } 134 135 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxorb_be 136 vector unsigned char test_vpermxorb_be(vector unsigned char a, 137 vector unsigned char b, 138 vector unsigned char c) { 139 return __builtin_altivec_crypto_vpermxor_be(a, b, c); 140 // CHECK: @llvm.ppc.altivec.crypto.vpermxor.be 141 } 142 143 // CHECK-LABEL: define{{.*}} <8 x i16> @test_vpermxorh_be 144 vector unsigned short test_vpermxorh_be(vector unsigned short a, 145 vector unsigned short b, 146 vector unsigned short c) { 147 return __builtin_altivec_crypto_vpermxor_be(a, b, c); 148 // CHECK: @llvm.ppc.altivec.crypto.vpermxor.be 149 } 150 151 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vpermxorw_be 152 vector unsigned int test_vpermxorw_be(vector unsigned int a, 153 vector unsigned int b, 154 vector unsigned int c) { 155 return __builtin_altivec_crypto_vpermxor_be(a, b, c); 156 // CHECK: @llvm.ppc.altivec.crypto.vpermxor.be 157 } 158 159 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vpermxord_be 160 vector unsigned long long test_vpermxord_be(vector unsigned long long a, 161 vector unsigned long long b, 162 vector unsigned long long c) { 163 return __builtin_altivec_crypto_vpermxor_be(a, b, c); 164 // CHECK: @llvm.ppc.altivec.crypto.vpermxor.be 165 } 166 167 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxorbc_be 168 vector bool char test_vpermxorbc_be(vector bool char a, 169 vector bool char b, 170 vector bool char c) { 171 return __builtin_altivec_crypto_vpermxor_be(a, b, c); 172 // CHECK: @llvm.ppc.altivec.crypto.vpermxor.be 173 } 174 175 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxorsc_be 176 vector signed char test_vpermxorsc_be(vector signed char a, 177 vector signed char b, 178 vector signed char c) { 179 return __builtin_altivec_crypto_vpermxor_be(a, b, c); 180 // CHECK: @llvm.ppc.altivec.crypto.vpermxor.be 181 } 182 183 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxoruc_be 184 vector unsigned char test_vpermxoruc_be(vector unsigned char a, 185 vector unsigned char b, 186 vector unsigned char c) { 187 return __builtin_altivec_crypto_vpermxor_be(a, b, c); 188 // CHECK: @llvm.ppc.altivec.crypto.vpermxor.be 189 } 190 191 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vcipher 192 vector unsigned long long test_vcipher(void) 193 { 194 vector unsigned long long a = D_INIT1 195 vector unsigned long long b = D_INIT2 196 return __builtin_altivec_crypto_vcipher(a, b); 197 // CHECK: @llvm.ppc.altivec.crypto.vcipher 198 } 199 200 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vcipherlast 201 vector unsigned long long test_vcipherlast(void) 202 { 203 vector unsigned long long a = D_INIT1 204 vector unsigned long long b = D_INIT2 205 return __builtin_altivec_crypto_vcipherlast(a, b); 206 // CHECK: @llvm.ppc.altivec.crypto.vcipherlast 207 } 208 209 // CHECK-LABEL: @test_vncipher 210 vector unsigned long long test_vncipher(void) 211 { 212 vector unsigned long long a = D_INIT1 213 vector unsigned long long b = D_INIT2 214 return __builtin_altivec_crypto_vncipher(a, b); 215 // CHECK: @llvm.ppc.altivec.crypto.vncipher 216 } 217 218 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vncipherlast 219 vector unsigned long long test_vncipherlast(void) 220 { 221 vector unsigned long long a = D_INIT1 222 vector unsigned long long b = D_INIT2 223 return __builtin_altivec_crypto_vncipherlast(a, b); 224 // CHECK: @llvm.ppc.altivec.crypto.vncipherlast 225 } 226 227 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vshasigmaw 228 vector unsigned int test_vshasigmaw(void) 229 { 230 vector unsigned int a = W_INIT1 231 return __builtin_altivec_crypto_vshasigmaw(a, 1, 15); 232 // CHECK: @llvm.ppc.altivec.crypto.vshasigmaw 233 } 234 235 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vshasigmad 236 vector unsigned long long test_vshasigmad(void) 237 { 238 vector unsigned long long a = D_INIT2 239 return __builtin_altivec_crypto_vshasigmad(a, 1, 15); 240 // CHECK: @llvm.ppc.altivec.crypto.vshasigmad 241 } 242 243 // Test cases for the builtins the way they are exposed to 244 // users through altivec.h 245 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vpmsumb_e 246 vector unsigned char test_vpmsumb_e(void) 247 { 248 vector unsigned char a = B_INIT1 249 vector unsigned char b = B_INIT2 250 return __builtin_crypto_vpmsumb(a, b); 251 // CHECK: @llvm.ppc.altivec.crypto.vpmsumb 252 } 253 254 // CHECK-LABEL: define{{.*}} <8 x i16> @test_vpmsumh_e 255 vector unsigned short test_vpmsumh_e(void) 256 { 257 vector unsigned short a = H_INIT1 258 vector unsigned short b = H_INIT2 259 return __builtin_crypto_vpmsumb(a, b); 260 // CHECK: @llvm.ppc.altivec.crypto.vpmsumh 261 } 262 263 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vpmsumw_e 264 vector unsigned int test_vpmsumw_e(void) 265 { 266 vector unsigned int a = W_INIT1 267 vector unsigned int b = W_INIT2 268 return __builtin_crypto_vpmsumb(a, b); 269 // CHECK: @llvm.ppc.altivec.crypto.vpmsumw 270 } 271 272 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vpmsumd_e 273 vector unsigned long long test_vpmsumd_e(void) 274 { 275 vector unsigned long long a = D_INIT1 276 vector unsigned long long b = D_INIT2 277 return __builtin_crypto_vpmsumb(a, b); 278 // CHECK: @llvm.ppc.altivec.crypto.vpmsumd 279 } 280 281 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vsbox_e 282 vector unsigned long long test_vsbox_e(void) 283 { 284 vector unsigned long long a = D_INIT1 285 return __builtin_crypto_vsbox(a); 286 // CHECK: @llvm.ppc.altivec.crypto.vsbox 287 } 288 289 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxorb_e 290 vector unsigned char test_vpermxorb_e(void) 291 { 292 vector unsigned char a = B_INIT1 293 vector unsigned char b = B_INIT2 294 vector unsigned char c = B_INIT2 295 return __builtin_crypto_vpermxor(a, b, c); 296 // CHECK: @llvm.ppc.altivec.crypto.vpermxor 297 } 298 299 // CHECK-LABEL: define{{.*}} <8 x i16> @test_vpermxorh_e 300 vector unsigned short test_vpermxorh_e(void) 301 { 302 vector unsigned short a = H_INIT1 303 vector unsigned short b = H_INIT2 304 vector unsigned short c = H_INIT2 305 return __builtin_crypto_vpermxor(a, b, c); 306 // CHECK: @llvm.ppc.altivec.crypto.vpermxor 307 } 308 309 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vpermxorw_e 310 vector unsigned int test_vpermxorw_e(void) 311 { 312 vector unsigned int a = W_INIT1 313 vector unsigned int b = W_INIT2 314 vector unsigned int c = W_INIT2 315 return __builtin_crypto_vpermxor(a, b, c); 316 // CHECK: @llvm.ppc.altivec.crypto.vpermxor 317 } 318 319 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vpermxord_e 320 vector unsigned long long test_vpermxord_e(void) 321 { 322 vector unsigned long long a = D_INIT1 323 vector unsigned long long b = D_INIT2 324 vector unsigned long long c = D_INIT2 325 return __builtin_crypto_vpermxor(a, b, c); 326 // CHECK: @llvm.ppc.altivec.crypto.vpermxor 327 } 328 329 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vcipher_e 330 vector unsigned long long test_vcipher_e(void) 331 { 332 vector unsigned long long a = D_INIT1 333 vector unsigned long long b = D_INIT2 334 return __builtin_crypto_vcipher(a, b); 335 // CHECK: @llvm.ppc.altivec.crypto.vcipher 336 } 337 338 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vcipherlast_e 339 vector unsigned long long test_vcipherlast_e(void) 340 { 341 vector unsigned long long a = D_INIT1 342 vector unsigned long long b = D_INIT2 343 return __builtin_crypto_vcipherlast(a, b); 344 // CHECK: @llvm.ppc.altivec.crypto.vcipherlast 345 } 346 347 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vncipher_e 348 vector unsigned long long test_vncipher_e(void) 349 { 350 vector unsigned long long a = D_INIT1 351 vector unsigned long long b = D_INIT2 352 return __builtin_crypto_vncipher(a, b); 353 // CHECK: @llvm.ppc.altivec.crypto.vncipher 354 } 355 356 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vncipherlast_e 357 vector unsigned long long test_vncipherlast_e(void) 358 { 359 vector unsigned long long a = D_INIT1 360 vector unsigned long long b = D_INIT2 361 return __builtin_crypto_vncipherlast(a, b); 362 // CHECK: @llvm.ppc.altivec.crypto.vncipherlast 363 } 364 365 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vshasigmaw_e 366 vector unsigned int test_vshasigmaw_e(void) 367 { 368 vector unsigned int a = W_INIT1 369 return __builtin_crypto_vshasigmaw(a, 1, 15); 370 // CHECK: @llvm.ppc.altivec.crypto.vshasigmaw 371 } 372 373 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vshasigmad_e 374 vector unsigned long long test_vshasigmad_e(void) 375 { 376 vector unsigned long long a = D_INIT2 377 return __builtin_crypto_vshasigmad(a, 0, 15); 378 // CHECK: @llvm.ppc.altivec.crypto.vshasigmad 379 } 380 381 // CHECK-LABEL: @test_vec_sbox_be 382 vector unsigned char test_vec_sbox_be(void) 383 { 384 vector unsigned char a = B_INIT1 385 return vec_sbox_be(a); 386 // CHECK: @llvm.ppc.altivec.crypto.vsbox 387 } 388 389 // CHECK-LABEL: @test_vec_cipher_be 390 vector unsigned char test_vec_cipher_be(void) 391 { 392 vector unsigned char a = B_INIT1 393 vector unsigned char b = B_INIT2 394 return vec_cipher_be(a, b); 395 // CHECK: @llvm.ppc.altivec.crypto.vcipher 396 } 397 398 // CHECK-LABEL: @test_vec_cipherlast_be 399 vector unsigned char test_vec_cipherlast_be(void) 400 { 401 vector unsigned char a = B_INIT1 402 vector unsigned char b = B_INIT2 403 return vec_cipherlast_be(a, b); 404 // CHECK: @llvm.ppc.altivec.crypto.vcipherlast 405 } 406 407 // CHECK-LABEL: @test_vec_ncipher_be 408 vector unsigned char test_vec_ncipher_be(void) 409 { 410 vector unsigned char a = B_INIT1 411 vector unsigned char b = B_INIT2 412 return vec_ncipher_be(a, b); 413 // CHECK: @llvm.ppc.altivec.crypto.vncipher 414 } 415 416 // CHECK-LABEL: @test_vec_ncipherlast_be 417 vector unsigned char test_vec_ncipherlast_be(void) 418 { 419 vector unsigned char a = B_INIT1 420 vector unsigned char b = B_INIT2 421 return vec_ncipherlast_be(a, b); 422 // CHECK: @llvm.ppc.altivec.crypto.vncipherlast 423 } 424 425 // CHECK-LABEL: @test_vec_shasigma_bew 426 vector unsigned int test_vec_shasigma_bew(void) 427 { 428 vector unsigned int a = W_INIT1 429 return vec_shasigma_be(a, 1, 15); 430 // CHECK: @llvm.ppc.altivec.crypto.vshasigmaw 431 } 432 433 // CHECK-LABEL: @test_vec_shasigma_bed 434 vector unsigned long long test_vec_shasigma_bed(void) 435 { 436 vector unsigned long long a = D_INIT2 437 return vec_shasigma_be(a, 1, 15); 438 // CHECK: @llvm.ppc.altivec.crypto.vshasigmad 439 } 440 441 // CHECK-LABEL: @test_vec_pmsum_beb 442 vector unsigned short test_vec_pmsum_beb(void) 443 { 444 vector unsigned char a = B_INIT1 445 vector unsigned char b = B_INIT2 446 return vec_pmsum_be(a, b); 447 // CHECK: @llvm.ppc.altivec.crypto.vpmsumb 448 } 449 450 // CHECK-LABEL: @test_vec_pmsum_beh 451 vector unsigned int test_vec_pmsum_beh(void) 452 { 453 vector unsigned short a = H_INIT1 454 vector unsigned short b = H_INIT2 455 return vec_pmsum_be(a, b); 456 // CHECK: @llvm.ppc.altivec.crypto.vpmsumh 457 } 458 459 // CHECK-LABEL: @test_vec_pmsum_bew 460 vector unsigned long long test_vec_pmsum_bew(void) 461 { 462 vector unsigned int a = W_INIT1 463 vector unsigned int b = W_INIT2 464 return vec_pmsum_be(a, b); 465 // CHECK: @llvm.ppc.altivec.crypto.vpmsumw 466 } 467 468 // CHECK-LABEL: @test_vec_pmsum_bed 469 vector unsigned __int128 test_vec_pmsum_bed(void) 470 { 471 vector unsigned long long a = D_INIT1 472 vector unsigned long long b = D_INIT2 473 return vec_pmsum_be(a, b); 474 // CHECK: @llvm.ppc.altivec.crypto.vpmsumd 475 } 476 477