From: Jin-Gu Kang Date: Sat, 8 Jun 2013 02:15:36 +0000 (+0000) Subject: Added a type checking which handle the case of an ext vector and integral scalar X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cc28eff95644b247d2cac643ff83ff7db7d8adb2;p=clang Added a type checking which handle the case of an ext vector and integral scalar git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183602 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 478464c9ac..610dc28e3d 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -6411,12 +6411,19 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, return LHSType; } } - if (EltTy->isRealFloatingType() && RHSType->isScalarType() && - RHSType->isRealFloatingType()) { - int order = Context.getFloatingTypeOrder(EltTy, RHSType); - if (order > 0) - RHS = ImpCastExprToType(RHS.take(), EltTy, CK_FloatingCast); - if (order >= 0) { + if (EltTy->isRealFloatingType() && RHSType->isScalarType()) { + if (RHSType->isRealFloatingType()) { + int order = Context.getFloatingTypeOrder(EltTy, RHSType); + if (order > 0) + RHS = ImpCastExprToType(RHS.take(), EltTy, CK_FloatingCast); + if (order >= 0) { + RHS = ImpCastExprToType(RHS.take(), LHSType, CK_VectorSplat); + if (swapped) std::swap(RHS, LHS); + 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; diff --git a/test/CodeGen/ext-vector.c b/test/CodeGen/ext-vector.c index a9fa151175..6fcefbfd35 100644 --- a/test/CodeGen/ext-vector.c +++ b/test/CodeGen/ext-vector.c @@ -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; +}