Skip to content

Commit 350d43f

Browse files
committed
Fix a bug where an extended vector of __fp16 was being converted to a
generic vector type rdar://86109177
1 parent ce21c92 commit 350d43f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Diff for: clang/lib/Sema/SemaExpr.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -10069,9 +10069,11 @@ static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar,
1006910069
static ExprResult convertVector(Expr *E, QualType ElementType, Sema &S) {
1007010070
const auto *VecTy = E->getType()->getAs<VectorType>();
1007110071
assert(VecTy && "Expression E must be a vector");
10072-
QualType NewVecTy = S.Context.getVectorType(ElementType,
10073-
VecTy->getNumElements(),
10074-
VecTy->getVectorKind());
10072+
QualType NewVecTy =
10073+
VecTy->isExtVectorType()
10074+
? S.Context.getExtVectorType(ElementType, VecTy->getNumElements())
10075+
: S.Context.getVectorType(ElementType, VecTy->getNumElements(),
10076+
VecTy->getVectorKind());
1007510077

1007610078
// Look through the implicit cast. Return the subexpression if its type is
1007710079
// NewVecTy.

Diff for: clang/test/Sema/fp16vec-sema.c

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ typedef __fp16 half4 __attribute__ ((vector_size (8)));
44
typedef float float4 __attribute__ ((vector_size (16)));
55
typedef short short4 __attribute__ ((vector_size (8)));
66
typedef int int4 __attribute__ ((vector_size (16)));
7+
typedef __fp16 exthalf4 __attribute__((ext_vector_type(4)));
78

89
half4 hv0, hv1;
910
float4 fv0, fv1;
@@ -51,3 +52,8 @@ void testFP16Vec(int c) {
5152
hv0++; // expected-error{{cannot increment value of type}}
5253
++hv0; // expected-error{{cannot increment value of type}}
5354
}
55+
56+
void testExtVec(exthalf4 a) {
57+
// Check that the type of "(-a)" is exthalf4.
58+
__fp16 t0 = (-a).z;
59+
}

0 commit comments

Comments
 (0)