Skip to content

Commit 6a8462e

Browse files
iamloukJulienVillette
authored andcommitted
[clang][AArch64/SVE] Avoid crash when checking conversion between SVL type and SVE tuple (fixes llvm#26)
1 parent adc5f60 commit 6a8462e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

clang/lib/AST/ASTContext.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10086,6 +10086,13 @@ bool ASTContext::areCompatibleSveTypes(QualType FirstType,
1008610086
QualType SecondType) {
1008710087
auto IsValidCast = [this](QualType FirstType, QualType SecondType) {
1008810088
if (const auto *BT = FirstType->getAs<BuiltinType>()) {
10089+
// SVE tuple types such as svuint32x4_t are SVE builtin types as well,
10090+
// but they are not compatible for casts to/from normal vectors.
10091+
// isSveVLSBuiltinType() happes to only over the vectors, and not the
10092+
// tuples.
10093+
if (!BT->isSveVLSBuiltinType())
10094+
return false;
10095+
1008910096
if (const auto *VT = SecondType->getAs<VectorType>()) {
1009010097
// Predicates have the same representation as uint8 so we also have to
1009110098
// check the kind to make these types incompatible.

clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,14 @@ fixed_int32_t to_fixed_int32_t__from_gnu_int32_t(gnu_int32_t type) {
111111
gnu_int32_t from_fixed_int32_t__to_gnu_int32_t(fixed_int32_t type) {
112112
return type;
113113
}
114+
115+
// Regression test for SiPearl-internal error:
116+
// https://gitlab01.int.sipearl.com/software/compilers/llvm-project-sipearl-fork/-/issues/26
117+
// CHECK-LABEL: @reinterpret_from_fixed_to_scalable(
118+
// CHECK-NEXT: entry:
119+
// CHECK-NEXT: [[TMP0:%.*]] = bitcast <vscale x 4 x i32> [[A_COERCE:%.*]] to <vscale x 4 x float>
120+
// CHECK-NEXT: ret <vscale x 4 x float> [[TMP0]]
121+
//
122+
svfloat32_t reinterpret_from_fixed_to_scalable(fixed_int32_t a) {
123+
return svreinterpret_f32(a);
124+
}

0 commit comments

Comments
 (0)