]> granicus.if.org Git - clang/commitdiff
Added a type checking which handle the case of an ext vector and integral scalar
authorJin-Gu Kang <jaykang10@imrc.kist.re.kr>
Sat, 8 Jun 2013 02:15:36 +0000 (02:15 +0000)
committerJin-Gu Kang <jaykang10@imrc.kist.re.kr>
Sat, 8 Jun 2013 02:15:36 +0000 (02:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183602 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/CodeGen/ext-vector.c

index 478464c9ac268c80c53893aa123cd6f92a7ba6e2..610dc28e3d9cedaab104358790f16a1375bece9b 100644 (file)
@@ -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;
index a9fa1511758be8f6fdb7085fd5d382ff7226c49c..6fcefbfd358185712392725a9e0a1ee7dc42bc41 100644 (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;
+}