]> granicus.if.org Git - clang/commitdiff
AltiVec vector comparison logic now affect only vectors of fundamental AltiVec vector...
authorAnton Yartsev <anton.yartsev@gmail.com>
Sun, 27 Mar 2011 15:36:07 +0000 (15:36 +0000)
committerAnton Yartsev <anton.yartsev@gmail.com>
Sun, 27 Mar 2011 15:36:07 +0000 (15:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128381 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprScalar.cpp
lib/Sema/SemaExpr.cpp
test/Sema/vector-ops.c

index 27b868974d5d1c84cb7079fbf2782868e51a8234..c6a5a40d768ec390c2809004129eb1f4e0f4942a 100644 (file)
@@ -2119,7 +2119,9 @@ Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc,
 
     // If AltiVec, the comparison results in a numeric type, so we use
     // intrinsics comparing vectors and giving 0 or 1 as a result
-    if (LHSTy->isVectorType() && CGF.getContext().getLangOptions().AltiVec) {
+    if (LHSTy->isVectorType() &&
+        LHSTy->getAs<VectorType>()->getVectorKind() ==
+          VectorType::AltiVecVector) {
       // constants for mapping CR6 register bits to predicate result
       enum { CR6_EQ=0, CR6_EQ_REV, CR6_LT, CR6_LT_REV } CR6;
 
index b5c67b8fe66fec79afe1fb91f5f0b52074fc71f4..214edf145c0f8d0b030e2bd4e7f7b00994a14181 100644 (file)
@@ -7277,14 +7277,16 @@ QualType Sema::CheckVectorCompareOperands(Expr *&lex, Expr *&rex,
   if (vType.isNull())
     return vType;
 
+  QualType lType = lex->getType();
+  QualType rType = rex->getType();
+
   // If AltiVec, the comparison results in a numeric type, i.e.
   // bool for C++, int for C
-  if (getLangOptions().AltiVec)
+  if (lType->getAs<VectorType>()->getVectorKind() == VectorType::AltiVecVector
+      && rType->getAs<VectorType>()->getVectorKind() ==
+         VectorType::AltiVecVector)
     return Context.getLogicalOperationType();
 
-  QualType lType = lex->getType();
-  QualType rType = rex->getType();
-
   // For non-floating point types, check for self-comparisons of the form
   // x == x, x != x, x < x, etc.  These always evaluate to a constant, and
   // often indicate logic errors in the program.
index 20575ec510c31843691b65d47c8ab6261e2fa17e..ca397375d73921a59dc7a87c22a2f9545821fe79 100644 (file)
@@ -12,6 +12,9 @@ void test1(v2u v2ua, v2s v2sa, v2f v2fa) {
   (void)(~v2ua);
   (void)(~v2fa); // expected-error{{invalid argument type 'v2f' to unary}}
 
+  // Comparison operators
+  v2ua = (v2ua==v2sa);
+
   // Arrays
   int array1[v2ua]; // expected-error{{size of array has non-integer type 'v2u'}}
   int array2[17];