Skip to content
Snippets Groups Projects
Commit 350d43f1 authored by Akira Hatanaka's avatar Akira Hatanaka
Browse files

Fix a bug where an extended vector of __fp16 was being converted to a

generic vector type

rdar://86109177
parent ce21c926
No related branches found
No related tags found
No related merge requests found
......@@ -10069,9 +10069,11 @@ static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar,
static ExprResult convertVector(Expr *E, QualType ElementType, Sema &S) {
const auto *VecTy = E->getType()->getAs<VectorType>();
assert(VecTy && "Expression E must be a vector");
QualType NewVecTy = S.Context.getVectorType(ElementType,
VecTy->getNumElements(),
VecTy->getVectorKind());
QualType NewVecTy =
VecTy->isExtVectorType()
? S.Context.getExtVectorType(ElementType, VecTy->getNumElements())
: S.Context.getVectorType(ElementType, VecTy->getNumElements(),
VecTy->getVectorKind());
 
// Look through the implicit cast. Return the subexpression if its type is
// NewVecTy.
......
......@@ -4,6 +4,7 @@ typedef __fp16 half4 __attribute__ ((vector_size (8)));
typedef float float4 __attribute__ ((vector_size (16)));
typedef short short4 __attribute__ ((vector_size (8)));
typedef int int4 __attribute__ ((vector_size (16)));
typedef __fp16 exthalf4 __attribute__((ext_vector_type(4)));
half4 hv0, hv1;
float4 fv0, fv1;
......@@ -51,3 +52,8 @@ void testFP16Vec(int c) {
hv0++; // expected-error{{cannot increment value of type}}
++hv0; // expected-error{{cannot increment value of type}}
}
void testExtVec(exthalf4 a) {
// Check that the type of "(-a)" is exthalf4.
__fp16 t0 = (-a).z;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment