Skip to content

Commit 461a1bf

Browse files
ghehgsmeenai
authored andcommitted
[CIR][CIRGen] Correct isSized predicate for vector type (llvm#869)
As title, if element type of vector type is sized, then the vector type should be deemed sized. This would enable us generate code for neon without triggering assertion
1 parent 19acfe7 commit 461a1bf

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

clang/lib/CIR/CodeGen/CIRGenBuilder.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,9 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy {
6161
RecordNames["anon"] = 0; // in order to start from the name "anon.0"
6262
}
6363

64-
std::string getUniqueAnonRecordName() {
65-
return getUniqueRecordName("anon");
66-
}
64+
std::string getUniqueAnonRecordName() { return getUniqueRecordName("anon"); }
6765

68-
std::string getUniqueRecordName(const std::string& baseName) {
66+
std::string getUniqueRecordName(const std::string &baseName) {
6967
auto it = RecordNames.find(baseName);
7068
if (it == RecordNames.end()) {
7169
RecordNames[baseName] = 0;
@@ -500,6 +498,9 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy {
500498
mlir::cir::ArrayType, mlir::cir::BoolType, mlir::cir::IntType,
501499
mlir::cir::CIRFPTypeInterface>(ty))
502500
return true;
501+
if (mlir::isa<mlir::cir::VectorType>(ty)) {
502+
return isSized(mlir::cast<mlir::cir::VectorType>(ty).getEltType());
503+
}
503504
assert(0 && "Unimplemented size for type");
504505
return false;
505506
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %clang_cc1 -triple aarch64-none-linux-android24 -fclangir -emit-cir -target-feature +neon %s -o %t.cir
2+
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
3+
// RUN: %clang_cc1 -triple aarch64-none-linux-android24 -fclangir -emit-llvm -target-feature +neon %s -o %t.ll
4+
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
5+
6+
typedef __attribute__((neon_vector_type(8))) short c;
7+
void d() { c a[8]; }
8+
9+
// CIR-LABEL: d
10+
// CIR: {{%.*}} = cir.alloca !cir.array<!cir.vector<!s16i x 8> x 8>,
11+
// CIR-SAME: !cir.ptr<!cir.array<!cir.vector<!s16i x 8> x 8>>, ["a"]
12+
// CIR-SAME: {alignment = 16 : i64}
13+
14+
// LLVM-LABEL: d
15+
// LLVM: {{%.*}} = alloca [8 x <8 x i16>], i64 1, align 16

0 commit comments

Comments
 (0)