[clang] [llvm] [Clang] Allow vector and matrix type attributes for sub-byte _BitInt (PR #140253)

via cfe-commits cfe-commits at lists.llvm.org
Mon May 19 16:22:16 PDT 2025


================
@@ -571,6 +571,41 @@ void VectorTest(uint16_t4 first, uint16_t4 second) {
   // CHECK: %[[ADD:.+]] = add <3 x i16> %[[Shuffle]], %[[Shuffle1]]
 }
 
+typedef unsigned _BitInt(4) uint4_t4 __attribute__((ext_vector_type(4)));
+void VectorTest(uint4_t4 first, uint4_t4 second) {
+  // LIN64: define{{.*}} void @_Z10VectorTestDv4_DU4_S0_(i32 %{{.+}}, i32 %{{.+}})
+  // LIN32: define{{.*}} void @_Z10VectorTestDv4_DU4_S0_(<4 x i4> %{{.+}}, <4 x i4> %{{.+}})
+  // WIN64: define dso_local void @"?VectorTest@@YAXT?$__vector at U?$_UBitInt@$03 at __clang@@$03 at __clang@@0 at Z"(<4 x i4> %{{.+}}, <4 x i4> %{{.+}})
+  // WIN32: define dso_local void @"?VectorTest@@YAXT?$__vector at U?$_UBitInt@$03 at __clang@@$03 at __clang@@0 at Z"(<4 x i4> inreg %{{.+}}, <4 x i4> inreg %{{.+}})
+  first.xzw + second.zwx;
+  // CHECK: %[[Shuffle:.+]] = shufflevector <4 x i4> %{{.+}}, <4 x i4> poison, <3 x i32> <i32 0, i32 2, i32 3>
+  // CHECK: %[[Shuffle1:.+]] = shufflevector <4 x i4> %{{.+}}, <4 x i4> poison, <3 x i32> <i32 2, i32 3, i32 0>
+  // CHECK: %[[ADD:.+]] = add <3 x i4> %[[Shuffle]], %[[Shuffle1]]
+}
+
+typedef unsigned _BitInt(2) uint2_t2 __attribute__((ext_vector_type(2)));
+uint2_t2 TestBitIntVector2x2Alloca(uint2_t2 v1, uint2_t2 v2) {
+  // LIN64: define dso_local i16 @_Z25TestBitIntVector2x2AllocaDv2_DU2_S0_(i16 %[[V1Coerce:.+]], i16 %[[V2Coerce:.+]])
+  // LIN64: %[[RetVal:.+]] = alloca <2 x i2>, align 2
----------------
Sirraide wrote:

I would have also expected `i8` here but I’m not a codegen expert.

https://github.com/llvm/llvm-project/pull/140253


More information about the cfe-commits mailing list