Added a type checking which handle the case of an ext vector and integral scalar

llvm-svn: 183602
This commit is contained in:
Jin-Gu Kang 2013-06-08 02:15:36 +00:00
parent 60a2442476
commit 0b5ca604a9
2 changed files with 18 additions and 6 deletions

View File

@ -6411,8 +6411,8 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
return LHSType;
}
}
if (EltTy->isRealFloatingType() && RHSType->isScalarType() &&
RHSType->isRealFloatingType()) {
if (EltTy->isRealFloatingType() && RHSType->isScalarType()) {
if (RHSType->isRealFloatingType()) {
int order = Context.getFloatingTypeOrder(EltTy, RHSType);
if (order > 0)
RHS = ImpCastExprToType(RHS.take(), EltTy, CK_FloatingCast);
@ -6422,6 +6422,13 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
return LHSType;
}
}
if (RHSType->isIntegralType(Context)) {
RHS = ImpCastExprToType(RHS.take(), EltTy, CK_IntegralToFloating);
RHS = ImpCastExprToType(RHS.take(), LHSType, CK_VectorSplat);
if (swapped) std::swap(RHS, LHS);
return LHSType;
}
}
}
// Vectors of different size or scalar and non-ext-vector are errors.

View File

@ -286,3 +286,8 @@ int4 test15(uint4 V0) {
V = V || V;
return V;
}
// CHECK: @test16
void test16(float2 a, float2 b) {
float2 t0 = (a + b) / 2;
}