diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h index 224f4863554d..1d768d534d6c 100644 --- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h +++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h @@ -141,6 +141,8 @@ class CIRBaseBuilderTy : public mlir::OpBuilder { return getZeroAttr(complexType); if (auto arrTy = mlir::dyn_cast(ty)) return getZeroAttr(arrTy); + if (auto vecTy = mlir::dyn_cast(ty)) + return getZeroAttr(vecTy); if (auto ptrTy = mlir::dyn_cast(ty)) return getConstNullPtrAttr(ptrTy); if (auto RecordTy = mlir::dyn_cast(ty)) diff --git a/clang/test/CIR/CodeGen/vectype-ext.cpp b/clang/test/CIR/CodeGen/vectype-ext.cpp index d7702f1f9658..969600c0ebf5 100644 --- a/clang/test/CIR/CodeGen/vectype-ext.cpp +++ b/clang/test/CIR/CodeGen/vectype-ext.cpp @@ -10,6 +10,27 @@ typedef double vd2 __attribute__((ext_vector_type(2))); typedef long vl2 __attribute__((ext_vector_type(2))); typedef unsigned short vus2 __attribute__((ext_vector_type(2))); +vi4 vec_a; +// CIR: cir.global external @[[VEC_A:.*]] = #cir.zero : !cir.vector + +// LLVM: @[[VEC_A:.*]] = global <4 x i32> zeroinitializer + +vi3 vec_b; +// CIR: cir.global external @[[VEC_B:.*]] = #cir.zero : !cir.vector + +// LLVM: @[[VEC_B:.*]] = global <3 x i32> zeroinitializer + +vi2 vec_c; +// CIR: cir.global external @[[VEC_C:.*]] = #cir.zero : !cir.vector + +// LLVM: @[[VEC_C:.*]] = global <2 x i32> zeroinitializer + +vd2 d; + +// CIR: cir.global external @[[VEC_D:.*]] = #cir.zero : !cir.vector + +// LLVM: @[[VEC_D:.*]] = global <2 x double> zeroinitializer + // CIR: cir.func {{@.*vector_int_test.*}} // LLVM: define dso_local void {{@.*vector_int_test.*}} void vector_int_test(int x) { diff --git a/clang/test/CIR/CodeGen/vectype.cpp b/clang/test/CIR/CodeGen/vectype.cpp index c47de5a7279f..0389ad8b87ca 100644 --- a/clang/test/CIR/CodeGen/vectype.cpp +++ b/clang/test/CIR/CodeGen/vectype.cpp @@ -5,6 +5,15 @@ typedef double vd2 __attribute__((vector_size(16))); typedef long long vll2 __attribute__((vector_size(16))); typedef unsigned short vus2 __attribute__((vector_size(4))); +vi4 vec_a; +// CHECK: cir.global external @[[VEC_A:.*]] = #cir.zero : !cir.vector + +vd2 b; +// CHECK: cir.global external @[[VEC_B:.*]] = #cir.zero : !cir.vector + +vll2 c; +// CHECK: cir.global external @[[VEC_C:.*]] = #cir.zero : !cir.vector + void vector_int_test(int x, unsigned short usx) { // Vector constant.