1 // REQUIRES: powerpc-registered-target 2 // RUN: %clang_cc1 -flax-vector-conversions=none -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 -flax-vector-conversions=none -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: test_vpermxorbc 82 vector bool char test_vpermxorbc(vector bool char a, 83 vector bool char b, 84 vector bool char c) { 85 return vec_permxor(a, b, c); 86 // CHECK: @llvm.ppc.altivec.crypto.vpermxor 87 } 88 89 // CHECK-LABEL: test_vpermxorsc 90 vector signed char test_vpermxorsc(vector signed char a, 91 vector signed char b, 92 vector signed char c) { 93 return vec_permxor(a, b, c); 94 // CHECK: @llvm.ppc.altivec.crypto.vpermxor 95 } 96 97 // CHECK-LABEL: test_vpermxoruc 98 vector unsigned char test_vpermxoruc(vector unsigned char a, 99 vector unsigned char b, 100 vector unsigned char c) { 101 return vec_permxor(a, b, c); 102 // CHECK: @llvm.ppc.altivec.crypto.vpermxor 103 } 104 105 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxoruc_be 106 vector unsigned char test_vpermxoruc_be(vector unsigned char a, 107 vector unsigned char b, 108 vector unsigned char c) { 109 return __builtin_altivec_crypto_vpermxor_be(a, b, c); 110 // CHECK: @llvm.ppc.altivec.crypto.vpermxor.be 111 } 112 113 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vcipher 114 vector unsigned long long test_vcipher(void) 115 { 116 vector unsigned long long a = D_INIT1 117 vector unsigned long long b = D_INIT2 118 return __builtin_altivec_crypto_vcipher(a, b); 119 // CHECK: @llvm.ppc.altivec.crypto.vcipher 120 } 121 122 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vcipherlast 123 vector unsigned long long test_vcipherlast(void) 124 { 125 vector unsigned long long a = D_INIT1 126 vector unsigned long long b = D_INIT2 127 return __builtin_altivec_crypto_vcipherlast(a, b); 128 // CHECK: @llvm.ppc.altivec.crypto.vcipherlast 129 } 130 131 // CHECK-LABEL: @test_vncipher 132 vector unsigned long long test_vncipher(void) 133 { 134 vector unsigned long long a = D_INIT1 135 vector unsigned long long b = D_INIT2 136 return __builtin_altivec_crypto_vncipher(a, b); 137 // CHECK: @llvm.ppc.altivec.crypto.vncipher 138 } 139 140 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vncipherlast 141 vector unsigned long long test_vncipherlast(void) 142 { 143 vector unsigned long long a = D_INIT1 144 vector unsigned long long b = D_INIT2 145 return __builtin_altivec_crypto_vncipherlast(a, b); 146 // CHECK: @llvm.ppc.altivec.crypto.vncipherlast 147 } 148 149 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vshasigmaw 150 vector unsigned int test_vshasigmaw(void) 151 { 152 vector unsigned int a = W_INIT1 153 return __builtin_altivec_crypto_vshasigmaw(a, 1, 15); 154 // CHECK: @llvm.ppc.altivec.crypto.vshasigmaw 155 } 156 157 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vshasigmad 158 vector unsigned long long test_vshasigmad(void) 159 { 160 vector unsigned long long a = D_INIT2 161 return __builtin_altivec_crypto_vshasigmad(a, 1, 15); 162 // CHECK: @llvm.ppc.altivec.crypto.vshasigmad 163 } 164 165 // Test cases for the builtins the way they are exposed to 166 // users through altivec.h 167 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vpmsumb_e 168 vector unsigned char test_vpmsumb_e(void) 169 { 170 vector unsigned char a = B_INIT1 171 vector unsigned char b = B_INIT2 172 return __builtin_crypto_vpmsumb(a, b); 173 // CHECK: @llvm.ppc.altivec.crypto.vpmsumb 174 } 175 176 // CHECK-LABEL: define{{.*}} <8 x i16> @test_vpmsumh_e 177 vector unsigned short test_vpmsumh_e(void) 178 { 179 vector unsigned short a = H_INIT1 180 vector unsigned short b = H_INIT2 181 return __builtin_crypto_vpmsumb(a, b); 182 // CHECK: @llvm.ppc.altivec.crypto.vpmsumh 183 } 184 185 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vpmsumw_e 186 vector unsigned int test_vpmsumw_e(void) 187 { 188 vector unsigned int a = W_INIT1 189 vector unsigned int b = W_INIT2 190 return __builtin_crypto_vpmsumb(a, b); 191 // CHECK: @llvm.ppc.altivec.crypto.vpmsumw 192 } 193 194 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vpmsumd_e 195 vector unsigned long long test_vpmsumd_e(void) 196 { 197 vector unsigned long long a = D_INIT1 198 vector unsigned long long b = D_INIT2 199 return __builtin_crypto_vpmsumb(a, b); 200 // CHECK: @llvm.ppc.altivec.crypto.vpmsumd 201 } 202 203 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vsbox_e 204 vector unsigned long long test_vsbox_e(void) 205 { 206 vector unsigned long long a = D_INIT1 207 return __builtin_crypto_vsbox(a); 208 // CHECK: @llvm.ppc.altivec.crypto.vsbox 209 } 210 211 // CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxorb_e 212 vector unsigned char test_vpermxorb_e(void) 213 { 214 vector unsigned char a = B_INIT1 215 vector unsigned char b = B_INIT2 216 vector unsigned char c = B_INIT2 217 return __builtin_crypto_vpermxor(a, b, c); 218 // CHECK: @llvm.ppc.altivec.crypto.vpermxor 219 } 220 221 // CHECK-LABEL: define{{.*}} <8 x i16> @test_vpermxorh_e 222 vector unsigned short test_vpermxorh_e(void) 223 { 224 vector unsigned short a = H_INIT1 225 vector unsigned short b = H_INIT2 226 vector unsigned short c = H_INIT2 227 return __builtin_crypto_vpermxor(a, b, c); 228 // CHECK: @llvm.ppc.altivec.crypto.vpermxor 229 } 230 231 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vpermxorw_e 232 vector unsigned int test_vpermxorw_e(void) 233 { 234 vector unsigned int a = W_INIT1 235 vector unsigned int b = W_INIT2 236 vector unsigned int c = W_INIT2 237 return __builtin_crypto_vpermxor(a, b, c); 238 // CHECK: @llvm.ppc.altivec.crypto.vpermxor 239 } 240 241 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vpermxord_e 242 vector unsigned long long test_vpermxord_e(void) 243 { 244 vector unsigned long long a = D_INIT1 245 vector unsigned long long b = D_INIT2 246 vector unsigned long long c = D_INIT2 247 return __builtin_crypto_vpermxor(a, b, c); 248 // CHECK: @llvm.ppc.altivec.crypto.vpermxor 249 } 250 251 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vcipher_e 252 vector unsigned long long test_vcipher_e(void) 253 { 254 vector unsigned long long a = D_INIT1 255 vector unsigned long long b = D_INIT2 256 return __builtin_crypto_vcipher(a, b); 257 // CHECK: @llvm.ppc.altivec.crypto.vcipher 258 } 259 260 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vcipherlast_e 261 vector unsigned long long test_vcipherlast_e(void) 262 { 263 vector unsigned long long a = D_INIT1 264 vector unsigned long long b = D_INIT2 265 return __builtin_crypto_vcipherlast(a, b); 266 // CHECK: @llvm.ppc.altivec.crypto.vcipherlast 267 } 268 269 // CHECK-LABEL: define{{.*}} <4 x i32> @test_vshasigmaw_e 270 vector unsigned int test_vshasigmaw_e(void) 271 { 272 vector unsigned int a = W_INIT1 273 return __builtin_crypto_vshasigmaw(a, 1, 15); 274 // CHECK: @llvm.ppc.altivec.crypto.vshasigmaw 275 } 276 277 // CHECK-LABEL: define{{.*}} <2 x i64> @test_vshasigmad_e 278 vector unsigned long long test_vshasigmad_e(void) 279 { 280 vector unsigned long long a = D_INIT2 281 return __builtin_crypto_vshasigmad(a, 0, 15); 282 // CHECK: @llvm.ppc.altivec.crypto.vshasigmad 283 } 284 285 // CHECK-LABEL: @test_vec_sbox_be 286 vector unsigned long long test_vec_sbox_be(void) 287 { 288 vector unsigned long long a = D_INIT1 289 return vec_sbox_be(a); 290 // CHECK: @llvm.ppc.altivec.crypto.vsbox 291 } 292 293 // CHECK-LABEL: @test_vec_cipher_be 294 vector unsigned long long test_vec_cipher_be(void) 295 { 296 vector unsigned long long a = D_INIT1 297 vector unsigned long long b = D_INIT2 298 return vec_cipher_be(a, b); 299 // CHECK: @llvm.ppc.altivec.crypto.vcipher 300 } 301 302 // CHECK-LABEL: @test_vec_cipherlast_be 303 vector unsigned long long test_vec_cipherlast_be(void) 304 { 305 vector unsigned long long a = D_INIT1 306 vector unsigned long long b = D_INIT2 307 return vec_cipherlast_be(a, b); 308 // CHECK: @llvm.ppc.altivec.crypto.vcipherlast 309 } 310 311 // CHECK-LABEL: @test_vec_ncipher_be 312 vector unsigned long long test_vec_ncipher_be(void) 313 { 314 vector unsigned long long a = D_INIT1 315 vector unsigned long long b = D_INIT2 316 return vec_ncipher_be(a, b); 317 // CHECK: @llvm.ppc.altivec.crypto.vncipher 318 } 319 320 // CHECK-LABEL: @test_vec_ncipherlast_be 321 vector unsigned long long test_vec_ncipherlast_be(void) 322 { 323 vector unsigned long long a = D_INIT1 324 vector unsigned long long b = D_INIT2 325 return vec_ncipherlast_be(a, b); 326 // CHECK: @llvm.ppc.altivec.crypto.vncipherlast 327 } 328 329 // CHECK-LABEL: @test_vec_shasigma_bew 330 vector unsigned int test_vec_shasigma_bew(void) 331 { 332 vector unsigned int a = W_INIT1 333 return vec_shasigma_be(a, 1, 15); 334 // CHECK: @llvm.ppc.altivec.crypto.vshasigmaw 335 } 336 337 // CHECK-LABEL: @test_vec_shasigma_bed 338 vector unsigned long long test_vec_shasigma_bed(void) 339 { 340 vector unsigned long long a = D_INIT2 341 return vec_shasigma_be(a, 1, 15); 342 // CHECK: @llvm.ppc.altivec.crypto.vshasigmad 343 } 344 345 // CHECK-LABEL: @test_vec_pmsum_beb 346 vector unsigned char test_vec_pmsum_beb(void) 347 { 348 vector unsigned char a = B_INIT1 349 vector unsigned char b = B_INIT2 350 return vec_pmsum_be(a, b); 351 // CHECK: @llvm.ppc.altivec.crypto.vpmsumb 352 } 353 354 // CHECK-LABEL: @test_vec_pmsum_beh 355 vector unsigned short test_vec_pmsum_beh(void) 356 { 357 vector unsigned short a = H_INIT1 358 vector unsigned short b = H_INIT2 359 return vec_pmsum_be(a, b); 360 // CHECK: @llvm.ppc.altivec.crypto.vpmsumh 361 } 362 363 // CHECK-LABEL: @test_vec_pmsum_bew 364 vector unsigned int test_vec_pmsum_bew(void) 365 { 366 vector unsigned int a = W_INIT1 367 vector unsigned int b = W_INIT2 368 return vec_pmsum_be(a, b); 369 // CHECK: @llvm.ppc.altivec.crypto.vpmsumw 370 } 371 372 // CHECK-LABEL: @test_vec_pmsum_bed 373 vector unsigned long long test_vec_pmsum_bed(void) 374 { 375 vector unsigned long long a = D_INIT1 376 vector unsigned long long b = D_INIT2 377 return vec_pmsum_be(a, b); 378 // CHECK: @llvm.ppc.altivec.crypto.vpmsumd 379 } 380 381