|
4 | 4 | // RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
|
5 | 5 |
|
6 | 6 | typedef int vi4 __attribute__((ext_vector_type(4)));
|
| 7 | +typedef int vi3 __attribute__((ext_vector_type(3))); |
7 | 8 | typedef int vi2 __attribute__((ext_vector_type(2)));
|
8 | 9 | typedef double vd2 __attribute__((ext_vector_type(2)));
|
9 | 10 | typedef long vl2 __attribute__((ext_vector_type(2)));
|
@@ -349,6 +350,10 @@ void test_store() {
|
349 | 350 | // CIR-NEXT: %[[#PVECB:]] = cir.alloca !cir.vector<!s32i x 2>
|
350 | 351 | // LLVM-NEXT: %[[#PVECB:]] = alloca <2 x i32>
|
351 | 352 |
|
| 353 | + vi3 c = {}; |
| 354 | + // CIR-NEXT: %[[#PVECC:]] = cir.alloca !cir.vector<!s32i x 3> |
| 355 | + // LLVM-NEXT: %[[#PVECC:]] = alloca <3 x i32> |
| 356 | + |
352 | 357 | a.xy = b;
|
353 | 358 | // CIR: %[[#LOAD4RHS:]] = cir.load %{{[0-9]+}} : !cir.ptr<!cir.vector<!s32i x 2>>, !cir.vector<!s32i x 2>
|
354 | 359 | // CIR-NEXT: %[[#LOAD5LHS:]] = cir.load %{{[0-9]+}} : !cir.ptr<!cir.vector<!s32i x 4>>, !cir.vector<!s32i x 4>
|
@@ -388,6 +393,35 @@ void test_store() {
|
388 | 393 | // LLVM-NEXT: %[[#RESULT:]] = shufflevector <4 x i32> %[[#VECA]], <4 x i32> %[[#EXTVECB]], <4 x i32> <i32 4, i32 5, i32 2, i32 3>
|
389 | 394 | // LLVM-NEXT: store <4 x i32> %[[#RESULT]], ptr %[[#PVECA]], align 16
|
390 | 395 |
|
| 396 | + // OpenCL C Specification 6.3.7. Vector Components |
| 397 | + // The suffixes .lo (or .even) and .hi (or .odd) for a 3-component vector type |
| 398 | + // operate as if the 3-component vector type is a 4-component vector type with |
| 399 | + // the value in the w component undefined. |
| 400 | + b = c.hi; |
| 401 | + |
| 402 | + // CIR-NEXT: %[[#VECC:]] = cir.load %[[#PVECC]] : !cir.ptr<!cir.vector<!s32i x 3>>, !cir.vector<!s32i x 3> |
| 403 | + // CIR-NEXT: %[[#HIPART:]] = cir.vec.shuffle(%[[#VECC]], %[[#VECC]] : !cir.vector<!s32i x 3>) [#cir.int<2> : !s32i, #cir.int<3> : !s32i] : !cir.vector<!s32i x 2> |
| 404 | + // CIR-NEXT: cir.store %[[#HIPART]], %[[#PVECB]] : !cir.vector<!s32i x 2>, !cir.ptr<!cir.vector<!s32i x 2>> |
| 405 | + |
| 406 | + // LLVM-NEXT: %[[#VECC:]] = load <3 x i32>, ptr %[[#PVECC]], align 16 |
| 407 | + // LLVM-NEXT: %[[#HIPART:]] = shufflevector <3 x i32> %[[#VECC]], <3 x i32> %[[#VECC]], <2 x i32> <i32 2, i32 3> |
| 408 | + // LLVM-NEXT: store <2 x i32> %[[#HIPART]], ptr %[[#PVECB]], align 8 |
| 409 | + |
| 410 | + // c.hi is c[2, 3], in which 3 should be ignored in CIRGen for store |
| 411 | + c.hi = b; |
| 412 | + |
| 413 | + // CIR-NEXT: %[[#VECB:]] = cir.load %[[#PVECB]] : !cir.ptr<!cir.vector<!s32i x 2>>, !cir.vector<!s32i x 2> |
| 414 | + // CIR-NEXT: %[[#VECC:]] = cir.load %[[#PVECC]] : !cir.ptr<!cir.vector<!s32i x 3>>, !cir.vector<!s32i x 3> |
| 415 | + // CIR-NEXT: %[[#EXTVECB:]] = cir.vec.shuffle(%[[#VECB]], %[[#VECB]] : !cir.vector<!s32i x 2>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<-1> : !s32i] : !cir.vector<!s32i x 3> |
| 416 | + // CIR-NEXT: %[[#RESULT:]] = cir.vec.shuffle(%[[#VECC]], %[[#EXTVECB]] : !cir.vector<!s32i x 3>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<3> : !s32i] : !cir.vector<!s32i x 3> |
| 417 | + // CIR-NEXT: cir.store %[[#RESULT]], %[[#PVECC]] : !cir.vector<!s32i x 3>, !cir.ptr<!cir.vector<!s32i x 3>> |
| 418 | + |
| 419 | + // LLVM-NEXT: %[[#VECB:]] = load <2 x i32>, ptr %[[#PVECB]], align 8 |
| 420 | + // LLVM-NEXT: %[[#VECC:]] = load <3 x i32>, ptr %[[#PVECC]], align 16 |
| 421 | + // LLVM-NEXT: %[[#EXTVECB:]] = shufflevector <2 x i32> %[[#VECB]], <2 x i32> %[[#VECB]], <3 x i32> <i32 0, i32 1, i32 poison> |
| 422 | + // LLVM-NEXT: %[[#RESULT:]] = shufflevector <3 x i32> %[[#VECC]], <3 x i32> %[[#EXTVECB]], <3 x i32> <i32 0, i32 1, i32 3> |
| 423 | + // LLVM-NEXT: store <3 x i32> %[[#RESULT]], ptr %[[#PVECC]], align 16 |
| 424 | + |
391 | 425 | }
|
392 | 426 |
|
393 | 427 | // CIR: cir.func {{@.*test_build_lvalue.*}}
|
@@ -452,3 +486,27 @@ void test_build_lvalue() {
|
452 | 486 | // LLVM-NEXT: store i32 %[[#RESULT]], ptr %[[#ALLOCAR]], align 4
|
453 | 487 |
|
454 | 488 | }
|
| 489 | + |
| 490 | +// CIR: cir.func {{@.*test_vec3.*}} |
| 491 | +// LLVM: define void {{@.*test_vec3.*}} |
| 492 | +void test_vec3() { |
| 493 | + vi3 v = {}; |
| 494 | + // CIR-NEXT: %[[#PV:]] = cir.alloca !cir.vector<!s32i x 3>, !cir.ptr<!cir.vector<!s32i x 3>>, ["v", init] {alignment = 16 : i64} |
| 495 | + // CIR: %[[#VEC4:]] = cir.vec.shuffle(%{{[0-9]+}}, %{{[0-9]+}} : !cir.vector<!s32i x 3>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<-1> : !s32i] : !cir.vector<!s32i x 4> |
| 496 | + // CIR-NEXT: %[[#PV4:]] = cir.cast(bitcast, %[[#PV]] : !cir.ptr<!cir.vector<!s32i x 3>>), !cir.ptr<!cir.vector<!s32i x 4>> |
| 497 | + // CIR-NEXT: cir.store %[[#VEC4]], %[[#PV4]] : !cir.vector<!s32i x 4>, !cir.ptr<!cir.vector<!s32i x 4>> |
| 498 | + |
| 499 | + // LLVM-NEXT: %[[#PV:]] = alloca <3 x i32>, i64 1, align 16 |
| 500 | + // LLVM-NEXT: store <4 x i32> <i32 0, i32 0, i32 0, i32 undef>, ptr %[[#PV]], align 16 |
| 501 | + |
| 502 | + v + 1; |
| 503 | + // CIR-NEXT: %[[#PV4:]] = cir.cast(bitcast, %[[#PV]] : !cir.ptr<!cir.vector<!s32i x 3>>), !cir.ptr<!cir.vector<!s32i x 4>> |
| 504 | + // CIR-NEXT: %[[#V4:]] = cir.load %[[#PV4]] : !cir.ptr<!cir.vector<!s32i x 4>>, !cir.vector<!s32i x 4> |
| 505 | + // CIR-NEXT: %[[#V3:]] = cir.vec.shuffle(%[[#V4]], %[[#V4]] : !cir.vector<!s32i x 4>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i] : !cir.vector<!s32i x 3> |
| 506 | + // CIR: %[[#RES:]] = cir.binop(add, %[[#V3]], %{{[0-9]+}}) : !cir.vector<!s32i x 3> |
| 507 | + |
| 508 | + // LLVM-NEXT: %[[#V4:]] = load <4 x i32>, ptr %[[#PV:]], align 16 |
| 509 | + // LLVM-NEXT: %[[#V3:]] = shufflevector <4 x i32> %[[#V4]], <4 x i32> %[[#V4]], <3 x i32> <i32 0, i32 1, i32 2> |
| 510 | + // LLVM-NEXT: %[[#RES:]] = add <3 x i32> %[[#V3]], <i32 1, i32 1, i32 1> |
| 511 | + |
| 512 | +} |
0 commit comments