[clang] [CIR][AArch64] Lower NEON vzip intrinsics (PR #193658)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 22 21:15:26 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clangir
Author: Jiahao Guo (E00N777)
<details>
<summary>Changes</summary>
### Summary
Lower NEON::BI__builtin_neon_vzip_v and NEON::BI__builtin_neon_vzipq_v in CIRGenBuiltinAArch64.cpp by porting the existing incubator logic (`clangir/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp`) onto ClangIR: two bitcasts on the input vectors, two rounds of cir.vec.shuffle generating the low/high interleave patterns, each stored through a ptr_stride of the sret base pointer.
### Test
- test_vzip_mf8
- test_vzipq_mf8
I found that these two intrinsics are defined in `llvm-project/clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_untyped.c`, but this file seems to be a test suite specifically for the `mfloat8` type, so I did not remove their original test cases.
Some of the new CHECK lines additionally match a pair of bitcasts before the shuffle; this shape comes from arm_neon.h's inline wrappers, which re-cast typed vectors (e.g. <4 x i16>) through <8 x i8> before calling __builtin_neon_vzip_v. Variants whose element type is already i8 (s8/u8/p8/mf8) skip that round-trip and therefore have no bitcasts in the check lines.
---
Patch is 60.13 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/193658.diff
3 Files Affected:
- (modified) clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp (+24-1)
- (modified) clang/test/CodeGen/AArch64/neon/intrinsics.c (+357)
- (modified) clang/test/CodeGen/arm_neon_intrinsics.c (-376)
``````````diff
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
index ace8a5737f4bd..a8ee0aae07da9 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
@@ -2774,8 +2774,31 @@ CIRGenFunction::emitAArch64BuiltinExpr(unsigned builtinID, const CallExpr *expr,
case NEON::BI__builtin_neon_vtrnq_v:
case NEON::BI__builtin_neon_vuzp_v:
case NEON::BI__builtin_neon_vuzpq_v:
+ cgm.errorNYI(expr->getSourceRange(),
+ std::string("unimplemented AArch64 builtin call: ") +
+ getContext().BuiltinInfo.getName(builtinID));
+ return mlir::Value{};
case NEON::BI__builtin_neon_vzip_v:
- case NEON::BI__builtin_neon_vzipq_v:
+ case NEON::BI__builtin_neon_vzipq_v: {
+ ops[1] = builder.createBitcast(ops[1], ty);
+ ops[2] = builder.createBitcast(ops[2], ty);
+ // Adding a bitcast here as Ops[0] might be a void pointer.
+ mlir::Value baseAddr =
+ builder.createBitcast(ops[0], builder.getPointerTo(ty));
+ mlir::Value sv;
+ for (unsigned vi = 0; vi != 2; ++vi) {
+ llvm::SmallVector<int64_t, 16> indices;
+ for (unsigned i = 0, e = ty.getSize(); i != e; i += 2) {
+ indices.push_back((i + vi * e) >> 1);
+ indices.push_back(((i + vi * e) >> 1) + e);
+ }
+ cir::ConstantOp idx = builder.getConstInt(loc, builder.getSInt32Ty(), vi);
+ mlir::Value addr = builder.createPtrStride(loc, baseAddr, idx);
+ sv = builder.createVecShuffle(loc, ops[1], ops[2], indices);
+ (void)builder.CIRBaseBuilderTy::createStore(loc, sv, addr);
+ }
+ return sv;
+ }
case NEON::BI__builtin_neon_vqtbl1q_v:
case NEON::BI__builtin_neon_vqtbl2q_v:
case NEON::BI__builtin_neon_vqtbl3q_v:
diff --git a/clang/test/CodeGen/AArch64/neon/intrinsics.c b/clang/test/CodeGen/AArch64/neon/intrinsics.c
index b8863168d2886..d2574a4f5ccbf 100644
--- a/clang/test/CodeGen/AArch64/neon/intrinsics.c
+++ b/clang/test/CodeGen/AArch64/neon/intrinsics.c
@@ -4165,3 +4165,360 @@ float64_t test_vminnmvq_f64(float64x2_t a) {
// LLVM-NEXT: ret double [[VMINNMVQ_F64_I]]
return vminnmvq_f64(a);
}
+
+//===------------------------------------------------------===//
+// 2.1.9.10. Zip elements
+// https://arm-software.github.io/acle/neon_intrinsics/advsimd.html#zip-elements
+//===------------------------------------------------------===//
+
+// LLVM-LABEL: @test_vzip_s8(
+// CIR-LABEL: @vzip_s8(
+int8x8x2_t test_vzip_s8(int8x8_t a, int8x8_t b) {
+ // CIR: [[LO:%.*]] = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<8 x !s8i>) [#cir.int<0> : !s32i, #cir.int<8> : !s32i, #cir.int<1> : !s32i, #cir.int<9> : !s32i, #cir.int<2> : !s32i, #cir.int<10> : !s32i, #cir.int<3> : !s32i, #cir.int<11> : !s32i] : !cir.vector<8 x !s8i>
+ // CIR: cir.store [[LO]], %{{.*}} : !cir.vector<8 x !s8i>, !cir.ptr<!cir.vector<8 x !s8i>>
+ // CIR: [[HI:%.*]] = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<8 x !s8i>) [#cir.int<4> : !s32i, #cir.int<12> : !s32i, #cir.int<5> : !s32i, #cir.int<13> : !s32i, #cir.int<6> : !s32i, #cir.int<14> : !s32i, #cir.int<7> : !s32i, #cir.int<15> : !s32i] : !cir.vector<8 x !s8i>
+ // CIR: cir.store [[HI]], %{{.*}} : !cir.vector<8 x !s8i>, !cir.ptr<!cir.vector<8 x !s8i>>
+
+ // LLVM-SAME: <8 x i8> {{.*}} [[A:%.*]], <8 x i8> {{.*}} [[B:%.*]]) {{.*}} {
+ // LLVM: [[VZIP_LO:%.*]] = shufflevector <8 x i8> [[A]], <8 x i8> [[B]], <8 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11>
+ // LLVM: [[VZIP_HI:%.*]] = shufflevector <8 x i8> [[A]], <8 x i8> [[B]], <8 x i32> <i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
+ return vzip_s8(a, b);
+}
+
+// LLVM-LABEL: @test_vzip_s16(
+// CIR-LABEL: @vzip_s16(
+int16x4x2_t test_vzip_s16(int16x4_t a, int16x4_t b) {
+ // CIR: [[A_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s8i> -> !cir.vector<4 x !s16i>
+ // CIR: [[B_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s8i> -> !cir.vector<4 x !s16i>
+ // CIR: [[LO:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<4 x !s16i>) [#cir.int<0> : !s32i, #cir.int<4> : !s32i, #cir.int<1> : !s32i, #cir.int<5> : !s32i] : !cir.vector<4 x !s16i>
+ // CIR: cir.store [[LO]], %{{.*}} : !cir.vector<4 x !s16i>, !cir.ptr<!cir.vector<4 x !s16i>>
+ // CIR: [[HI:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<4 x !s16i>) [#cir.int<2> : !s32i, #cir.int<6> : !s32i, #cir.int<3> : !s32i, #cir.int<7> : !s32i] : !cir.vector<4 x !s16i>
+ // CIR: cir.store [[HI]], %{{.*}} : !cir.vector<4 x !s16i>, !cir.ptr<!cir.vector<4 x !s16i>>
+
+ // LLVM-SAME: <4 x i16> {{.*}} [[A:%.*]], <4 x i16> {{.*}} [[B:%.*]]) {{.*}} {
+ // LLVM: [[A_RAW:%.*]] = bitcast <4 x i16> [[A]] to <8 x i8>
+ // LLVM: [[B_RAW:%.*]] = bitcast <4 x i16> [[B]] to <8 x i8>
+ // LLVM: [[A_CAST:%.*]] = bitcast <8 x i8> [[A_RAW]] to <4 x i16>
+ // LLVM: [[B_CAST:%.*]] = bitcast <8 x i8> [[B_RAW]] to <4 x i16>
+ // LLVM: [[VZIP_LO:%.*]] = shufflevector <4 x i16> [[A_CAST]], <4 x i16> [[B_CAST]], <4 x i32> <i32 0, i32 4, i32 1, i32 5>
+ // LLVM: [[VZIP_HI:%.*]] = shufflevector <4 x i16> [[A_CAST]], <4 x i16> [[B_CAST]], <4 x i32> <i32 2, i32 6, i32 3, i32 7>
+ return vzip_s16(a, b);
+}
+
+// LLVM-LABEL: @test_vzip_u8(
+// CIR-LABEL: @vzip_u8(
+uint8x8x2_t test_vzip_u8(uint8x8_t a, uint8x8_t b) {
+ // CIR: [[A_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s8i> -> !cir.vector<8 x !u8i>
+ // CIR: [[B_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s8i> -> !cir.vector<8 x !u8i>
+ // CIR: [[LO:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<8 x !u8i>) [#cir.int<0> : !s32i, #cir.int<8> : !s32i, #cir.int<1> : !s32i, #cir.int<9> : !s32i, #cir.int<2> : !s32i, #cir.int<10> : !s32i, #cir.int<3> : !s32i, #cir.int<11> : !s32i] : !cir.vector<8 x !u8i>
+ // CIR: cir.store [[LO]], %{{.*}} : !cir.vector<8 x !u8i>, !cir.ptr<!cir.vector<8 x !u8i>>
+ // CIR: [[HI:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<8 x !u8i>) [#cir.int<4> : !s32i, #cir.int<12> : !s32i, #cir.int<5> : !s32i, #cir.int<13> : !s32i, #cir.int<6> : !s32i, #cir.int<14> : !s32i, #cir.int<7> : !s32i, #cir.int<15> : !s32i] : !cir.vector<8 x !u8i>
+ // CIR: cir.store [[HI]], %{{.*}} : !cir.vector<8 x !u8i>, !cir.ptr<!cir.vector<8 x !u8i>>
+
+ // LLVM-SAME: <8 x i8> {{.*}} [[A:%.*]], <8 x i8> {{.*}} [[B:%.*]]) {{.*}} {
+ // LLVM: [[VZIP_LO:%.*]] = shufflevector <8 x i8> [[A]], <8 x i8> [[B]], <8 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11>
+ // LLVM: [[VZIP_HI:%.*]] = shufflevector <8 x i8> [[A]], <8 x i8> [[B]], <8 x i32> <i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
+ return vzip_u8(a, b);
+}
+
+// LLVM-LABEL: @test_vzip_u16(
+// CIR-LABEL: @vzip_u16(
+uint16x4x2_t test_vzip_u16(uint16x4_t a, uint16x4_t b) {
+ // CIR: [[A_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s8i> -> !cir.vector<4 x !u16i>
+ // CIR: [[B_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s8i> -> !cir.vector<4 x !u16i>
+ // CIR: [[LO:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<4 x !u16i>) [#cir.int<0> : !s32i, #cir.int<4> : !s32i, #cir.int<1> : !s32i, #cir.int<5> : !s32i] : !cir.vector<4 x !u16i>
+ // CIR: cir.store [[LO]], %{{.*}} : !cir.vector<4 x !u16i>, !cir.ptr<!cir.vector<4 x !u16i>>
+ // CIR: [[HI:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<4 x !u16i>) [#cir.int<2> : !s32i, #cir.int<6> : !s32i, #cir.int<3> : !s32i, #cir.int<7> : !s32i] : !cir.vector<4 x !u16i>
+ // CIR: cir.store [[HI]], %{{.*}} : !cir.vector<4 x !u16i>, !cir.ptr<!cir.vector<4 x !u16i>>
+
+ // LLVM-SAME: <4 x i16> {{.*}} [[A:%.*]], <4 x i16> {{.*}} [[B:%.*]]) {{.*}} {
+ // LLVM: [[A_RAW:%.*]] = bitcast <4 x i16> [[A]] to <8 x i8>
+ // LLVM: [[B_RAW:%.*]] = bitcast <4 x i16> [[B]] to <8 x i8>
+ // LLVM: [[A_CAST:%.*]] = bitcast <8 x i8> [[A_RAW]] to <4 x i16>
+ // LLVM: [[B_CAST:%.*]] = bitcast <8 x i8> [[B_RAW]] to <4 x i16>
+ // LLVM: [[VZIP_LO:%.*]] = shufflevector <4 x i16> [[A_CAST]], <4 x i16> [[B_CAST]], <4 x i32> <i32 0, i32 4, i32 1, i32 5>
+ // LLVM: [[VZIP_HI:%.*]] = shufflevector <4 x i16> [[A_CAST]], <4 x i16> [[B_CAST]], <4 x i32> <i32 2, i32 6, i32 3, i32 7>
+ return vzip_u16(a, b);
+}
+
+// LLVM-LABEL: @test_vzip_p8(
+// CIR-LABEL: @vzip_p8(
+poly8x8x2_t test_vzip_p8(poly8x8_t a, poly8x8_t b) {
+ // CIR: [[LO:%.*]] = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<8 x !s8i>) [#cir.int<0> : !s32i, #cir.int<8> : !s32i, #cir.int<1> : !s32i, #cir.int<9> : !s32i, #cir.int<2> : !s32i, #cir.int<10> : !s32i, #cir.int<3> : !s32i, #cir.int<11> : !s32i] : !cir.vector<8 x !s8i>
+ // CIR: cir.store [[LO]], %{{.*}} : !cir.vector<8 x !s8i>, !cir.ptr<!cir.vector<8 x !s8i>>
+ // CIR: [[HI:%.*]] = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<8 x !s8i>) [#cir.int<4> : !s32i, #cir.int<12> : !s32i, #cir.int<5> : !s32i, #cir.int<13> : !s32i, #cir.int<6> : !s32i, #cir.int<14> : !s32i, #cir.int<7> : !s32i, #cir.int<15> : !s32i] : !cir.vector<8 x !s8i>
+ // CIR: cir.store [[HI]], %{{.*}} : !cir.vector<8 x !s8i>, !cir.ptr<!cir.vector<8 x !s8i>>
+
+ // LLVM-SAME: <8 x i8> {{.*}} [[A:%.*]], <8 x i8> {{.*}} [[B:%.*]]) {{.*}} {
+ // LLVM: [[VZIP_LO:%.*]] = shufflevector <8 x i8> [[A]], <8 x i8> [[B]], <8 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11>
+ // LLVM: [[VZIP_HI:%.*]] = shufflevector <8 x i8> [[A]], <8 x i8> [[B]], <8 x i32> <i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
+ return vzip_p8(a, b);
+}
+
+// LLVM-LABEL: @test_vzip_p16(
+// CIR-LABEL: @vzip_p16(
+poly16x4x2_t test_vzip_p16(poly16x4_t a, poly16x4_t b) {
+ // CIR: [[A_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s8i> -> !cir.vector<4 x !s16i>
+ // CIR: [[B_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s8i> -> !cir.vector<4 x !s16i>
+ // CIR: [[LO:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<4 x !s16i>) [#cir.int<0> : !s32i, #cir.int<4> : !s32i, #cir.int<1> : !s32i, #cir.int<5> : !s32i] : !cir.vector<4 x !s16i>
+ // CIR: cir.store [[LO]], %{{.*}} : !cir.vector<4 x !s16i>, !cir.ptr<!cir.vector<4 x !s16i>>
+ // CIR: [[HI:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<4 x !s16i>) [#cir.int<2> : !s32i, #cir.int<6> : !s32i, #cir.int<3> : !s32i, #cir.int<7> : !s32i] : !cir.vector<4 x !s16i>
+ // CIR: cir.store [[HI]], %{{.*}} : !cir.vector<4 x !s16i>, !cir.ptr<!cir.vector<4 x !s16i>>
+
+ // LLVM-SAME: <4 x i16> {{.*}} [[A:%.*]], <4 x i16> {{.*}} [[B:%.*]]) {{.*}} {
+ // LLVM: [[A_RAW:%.*]] = bitcast <4 x i16> [[A]] to <8 x i8>
+ // LLVM: [[B_RAW:%.*]] = bitcast <4 x i16> [[B]] to <8 x i8>
+ // LLVM: [[A_CAST:%.*]] = bitcast <8 x i8> [[A_RAW]] to <4 x i16>
+ // LLVM: [[B_CAST:%.*]] = bitcast <8 x i8> [[B_RAW]] to <4 x i16>
+ // LLVM: [[VZIP_LO:%.*]] = shufflevector <4 x i16> [[A_CAST]], <4 x i16> [[B_CAST]], <4 x i32> <i32 0, i32 4, i32 1, i32 5>
+ // LLVM: [[VZIP_HI:%.*]] = shufflevector <4 x i16> [[A_CAST]], <4 x i16> [[B_CAST]], <4 x i32> <i32 2, i32 6, i32 3, i32 7>
+ return vzip_p16(a, b);
+}
+
+// LLVM-LABEL: @test_vzip_mf8(
+// CIR-LABEL: @vzip_mf8(
+mfloat8x8x2_t test_vzip_mf8(mfloat8x8_t a, mfloat8x8_t b) {
+ // CIR: [[A_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s8i> -> !cir.vector<8 x !u8i>
+ // CIR: [[B_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s8i> -> !cir.vector<8 x !u8i>
+ // CIR: [[LO:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<8 x !u8i>) [#cir.int<0> : !s32i, #cir.int<8> : !s32i, #cir.int<1> : !s32i, #cir.int<9> : !s32i, #cir.int<2> : !s32i, #cir.int<10> : !s32i, #cir.int<3> : !s32i, #cir.int<11> : !s32i] : !cir.vector<8 x !u8i>
+ // CIR: cir.store [[LO]], %{{.*}} : !cir.vector<8 x !u8i>, !cir.ptr<!cir.vector<8 x !u8i>>
+ // CIR: [[HI:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<8 x !u8i>) [#cir.int<4> : !s32i, #cir.int<12> : !s32i, #cir.int<5> : !s32i, #cir.int<13> : !s32i, #cir.int<6> : !s32i, #cir.int<14> : !s32i, #cir.int<7> : !s32i, #cir.int<15> : !s32i] : !cir.vector<8 x !u8i>
+ // CIR: cir.store [[HI]], %{{.*}} : !cir.vector<8 x !u8i>, !cir.ptr<!cir.vector<8 x !u8i>>
+
+ // LLVM-SAME: <8 x i8> {{.*}}[[A:%.*]], <8 x i8> {{.*}}[[B:%.*]]) {{.*}} {
+ // LLVM: [[VZIP_LO:%.*]] = shufflevector <8 x i8> [[A]], <8 x i8> [[B]], <8 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11>
+ // LLVM: [[VZIP_HI:%.*]] = shufflevector <8 x i8> [[A]], <8 x i8> [[B]], <8 x i32> <i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
+ return vzip_mf8(a, b);
+}
+
+// LLVM-LABEL: @test_vzip_s32(
+// CIR-LABEL: @vzip_s32(
+int32x2x2_t test_vzip_s32(int32x2_t a, int32x2_t b) {
+ // CIR: [[A_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s8i> -> !cir.vector<2 x !s32i>
+ // CIR: [[B_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s8i> -> !cir.vector<2 x !s32i>
+ // CIR: [[LO:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<2 x !s32i>) [#cir.int<0> : !s32i, #cir.int<2> : !s32i] : !cir.vector<2 x !s32i>
+ // CIR: cir.store [[LO]], %{{.*}} : !cir.vector<2 x !s32i>, !cir.ptr<!cir.vector<2 x !s32i>>
+ // CIR: [[HI:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<2 x !s32i>) [#cir.int<1> : !s32i, #cir.int<3> : !s32i] : !cir.vector<2 x !s32i>
+ // CIR: cir.store [[HI]], %{{.*}} : !cir.vector<2 x !s32i>, !cir.ptr<!cir.vector<2 x !s32i>>
+
+ // LLVM-SAME: <2 x i32> {{.*}} [[A:%.*]], <2 x i32> {{.*}} [[B:%.*]]) {{.*}} {
+ // LLVM: [[A_RAW:%.*]] = bitcast <2 x i32> [[A]] to <8 x i8>
+ // LLVM: [[B_RAW:%.*]] = bitcast <2 x i32> [[B]] to <8 x i8>
+ // LLVM: [[A_CAST:%.*]] = bitcast <8 x i8> [[A_RAW]] to <2 x i32>
+ // LLVM: [[B_CAST:%.*]] = bitcast <8 x i8> [[B_RAW]] to <2 x i32>
+ // LLVM: [[VZIP_LO:%.*]] = shufflevector <2 x i32> [[A_CAST]], <2 x i32> [[B_CAST]], <2 x i32> <i32 0, i32 2>
+ // LLVM: [[VZIP_HI:%.*]] = shufflevector <2 x i32> [[A_CAST]], <2 x i32> [[B_CAST]], <2 x i32> <i32 1, i32 3>
+ return vzip_s32(a, b);
+}
+
+// LLVM-LABEL: @test_vzip_f32(
+// CIR-LABEL: @vzip_f32(
+float32x2x2_t test_vzip_f32(float32x2_t a, float32x2_t b) {
+ // CIR: [[A_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s8i> -> !cir.vector<2 x !cir.float>
+ // CIR: [[B_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s8i> -> !cir.vector<2 x !cir.float>
+ // CIR: [[LO:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<2 x !cir.float>) [#cir.int<0> : !s32i, #cir.int<2> : !s32i] : !cir.vector<2 x !cir.float>
+ // CIR: cir.store [[LO]], %{{.*}} : !cir.vector<2 x !cir.float>, !cir.ptr<!cir.vector<2 x !cir.float>>
+ // CIR: [[HI:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<2 x !cir.float>) [#cir.int<1> : !s32i, #cir.int<3> : !s32i] : !cir.vector<2 x !cir.float>
+ // CIR: cir.store [[HI]], %{{.*}} : !cir.vector<2 x !cir.float>, !cir.ptr<!cir.vector<2 x !cir.float>>
+
+ // LLVM-SAME: <2 x float> {{.*}} [[A:%.*]], <2 x float> {{.*}} [[B:%.*]]) {{.*}} {
+ // LLVM: [[VZIP_LO:%.*]] = shufflevector <2 x float> {{.*}}, <2 x float> {{.*}}, <2 x i32> <i32 0, i32 2>
+ // LLVM: [[VZIP_HI:%.*]] = shufflevector <2 x float> {{.*}}, <2 x float> {{.*}}, <2 x i32> <i32 1, i32 3>
+ return vzip_f32(a, b);
+}
+
+// LLVM-LABEL: @test_vzip_u32(
+// CIR-LABEL: @vzip_u32(
+uint32x2x2_t test_vzip_u32(uint32x2_t a, uint32x2_t b) {
+ // CIR: [[A_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s8i> -> !cir.vector<2 x !u32i>
+ // CIR: [[B_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s8i> -> !cir.vector<2 x !u32i>
+ // CIR: [[LO:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<2 x !u32i>) [#cir.int<0> : !s32i, #cir.int<2> : !s32i] : !cir.vector<2 x !u32i>
+ // CIR: cir.store [[LO]], %{{.*}} : !cir.vector<2 x !u32i>, !cir.ptr<!cir.vector<2 x !u32i>>
+ // CIR: [[HI:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<2 x !u32i>) [#cir.int<1> : !s32i, #cir.int<3> : !s32i] : !cir.vector<2 x !u32i>
+ // CIR: cir.store [[HI]], %{{.*}} : !cir.vector<2 x !u32i>, !cir.ptr<!cir.vector<2 x !u32i>>
+
+ // LLVM-SAME: <2 x i32> {{.*}} [[A:%.*]], <2 x i32> {{.*}} [[B:%.*]]) {{.*}} {
+ // LLVM: [[A_RAW:%.*]] = bitcast <2 x i32> [[A]] to <8 x i8>
+ // LLVM: [[B_RAW:%.*]] = bitcast <2 x i32> [[B]] to <8 x i8>
+ // LLVM: [[A_CAST:%.*]] = bitcast <8 x i8> [[A_RAW]] to <2 x i32>
+ // LLVM: [[B_CAST:%.*]] = bitcast <8 x i8> [[B_RAW]] to <2 x i32>
+ // LLVM: [[VZIP_LO:%.*]] = shufflevector <2 x i32> [[A_CAST]], <2 x i32> [[B_CAST]], <2 x i32> <i32 0, i32 2>
+ // LLVM: [[VZIP_HI:%.*]] = shufflevector <2 x i32> [[A_CAST]], <2 x i32> [[B_CAST]], <2 x i32> <i32 1, i32 3>
+ return vzip_u32(a, b);
+}
+
+// LLVM-LABEL: @test_vzipq_s8(
+// CIR-LABEL: @vzipq_s8(
+int8x16x2_t test_vzipq_s8(int8x16_t a, int8x16_t b) {
+ // CIR: [[LO:%.*]] = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<16 x !s8i>) [#cir.int<0> : !s32i, #cir.int<16> : !s32i, #cir.int<1> : !s32i, #cir.int<17> : !s32i, #cir.int<2> : !s32i, #cir.int<18> : !s32i, #cir.int<3> : !s32i, #cir.int<19> : !s32i, #cir.int<4> : !s32i, #cir.int<20> : !s32i, #cir.int<5> : !s32i, #cir.int<21> : !s32i, #cir.int<6> : !s32i, #cir.int<22> : !s32i, #cir.int<7> : !s32i, #cir.int<23> : !s32i] : !cir.vector<16 x !s8i>
+ // CIR: cir.store [[LO]], %{{.*}} : !cir.vector<16 x !s8i>, !cir.ptr<!cir.vector<16 x !s8i>>
+ // CIR: [[HI:%.*]] = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<16 x !s8i>) [#cir.int<8> : !s32i, #cir.int<24> : !s32i, #cir.int<9> : !s32i, #cir.int<25> : !s32i, #cir.int<10> : !s32i, #cir.int<26> : !s32i, #cir.int<11> : !s32i, #cir.int<27> : !s32i, #cir.int<12> : !s32i, #cir.int<28> : !s32i, #cir.int<13> : !s32i, #cir.int<29> : !s32i, #cir.int<14> : !s32i, #cir.int<30> : !s32i, #cir.int<15> : !s32i, #cir.int<31> : !s32i] : !cir.vector<16 x !s8i>
+ // CIR: cir.store [[HI]], %{{.*}} : !cir.vector<16 x !s8i>, !cir.ptr<!cir.vector<16 x !s8i>>
+
+ // LLVM-SAME: <16 x i8> {{.*}} [[A:%.*]], <16 x i8> {{.*}} [[B:%.*]]) {{.*}} {
+ // LLVM: [[VZIP_LO:%.*]] = shufflevector <16 x i8> [[A]], <16 x i8> [[B]], <16 x i32> <i32 0, i32 16, i32 1, i32 17, i32 2, i32 18, i32 3, i32 19, i32 4, i32 20, i32 5, i32 21, i32 6, i32 22, i32 7, i32 23>
+ // LLVM: [[VZIP_HI:%.*]] = shufflevector <16 x i8> [[A]], <16 x i8> [[B]], <16 x i32> <i32 8, i32 24, i32 9, i32 25, i32 10, i32 26, i32 11, i32 27, i32 12, i32 28, i32 13, i32 29, i32 14, i32 30, i32 15, i32 31>
+ return vzipq_s8(a, b);
+}
+
+// LLVM-LABEL: @test_vzipq_s16(
+// CIR-LABEL: @vzipq_s16(
+int16x8x2_t test_vzipq_s16(int16x8_t a, int16x8_t b) {
+ // CIR: [[A_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<16 x !s8i> -> !cir.vector<8 x !s16i>
+ // CIR: [[B_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<16 x !s8i> -> !cir.vector<8 x !s16i>
+ // CIR: [[LO:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<8 x !s16i>) [#cir.int<0> : !s32i, #cir.int<8> : !s32i, #cir.int<1> : !s32i, #cir.int<9> : !s32i, #cir.int<2> : !s32i, #cir.int<10> : !s32i, #cir.int<3> : !s32i, #cir.int<11> : !s32i] : !cir.vector<8 x !s16i>
+ // CIR: cir.store [[LO]], %{{.*}} : !cir.vector<8 x !s16i>, !cir.ptr<!cir.vector<8 x !s16i>>
+ // CIR: [[HI:%.*]] = cir.vec.shuffle([[A_CAST]], [[B_CAST]] : !cir.vector<8 x !s16i>) [#cir.int<4> : !s32i, #cir.int<12> : !s32i, #cir.int<5> : !s32i, #cir.int<13> : !s32i, #cir.int<6> : !s32i, #cir.int<14> : !s32i, #cir.int<7> : !s32i, #cir.int<15> : !s32i] : !cir.vector<8 x !s16i>
+ // CIR: cir.store [[HI]], %{{.*}} : !cir.vector<8 x !s16i>, !cir.ptr<!cir.vector<8 x !s16i>>
+
+ // LLVM-SAME: <8 x i16> {{.*}} [[A:%.*]], <8 x i16> {{.*}} [[B:%.*]]) {{.*}} {
+ // LLVM: [[A_RAW:%.*]] = bitcast <8 x i16> [[A]] to <16 x i8>
+ // LLVM: [[B_RAW:%.*]] = bitcast <8 x i16> [[B]] to <16 x i8>
+ // LLVM: [[A_CAST:%.*]] = bitcast <16 x i8> [[A_RAW]] to <8 x i16>
+ // LLVM: [[B_CAST:%.*]] = bitcast <16 x i8> [[B_RAW]] to <8 x i16>
+ // LLVM: [[VZIP_LO:%.*]] = shufflevector <8 x i16> [[A_CAST]], <8 x i16> [[B_CAST]], <8 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11>
+ // LLVM: [[VZIP_HI:%.*]] = shufflevector <8 x i16> [[A_CAST]], <8 x i16> [[B_CAST]], <8 x i32> <i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
+ return vzipq_s16(a, b);
+}
+
+// LLVM-LABEL: @test_vzipq_s32(
+// CIR-LABEL: @vzipq_s32(
+int32x4x2_t test_vzipq_s32(int32x4_t a, int32x4_t b) {
+ // CIR: [[A_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<16 x !s8i> -> !cir.vector<4 x !s32i>
+ // CIR: [[B_CAST:%.*]] = cir.cast bitcast %{{.*}} : !cir.vector<16 x !s8i> -> !ci...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/193658
More information about the cfe-commits
mailing list