[cfe-commits] r128381 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp lib/Sema/SemaExpr.cpp test/Sema/vector-ops.c

Anton Yartsev anton.yartsev at gmail.com
Sun Mar 27 08:36:07 PDT 2011


Author: ayartsev
Date: Sun Mar 27 10:36:07 2011
New Revision: 128381

URL: http://llvm.org/viewvc/llvm-project?rev=128381&view=rev
Log:
AltiVec vector comparison logic now affect only vectors of fundamental AltiVec vector types. It fixes bug 9347. 

Modified:
    cfe/trunk/lib/CodeGen/CGExprScalar.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/Sema/vector-ops.c

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=128381&r1=128380&r2=128381&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Sun Mar 27 10:36:07 2011
@@ -2119,7 +2119,9 @@
 
     // 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;
 

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=128381&r1=128380&r2=128381&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Mar 27 10:36:07 2011
@@ -7277,14 +7277,16 @@
   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.

Modified: cfe/trunk/test/Sema/vector-ops.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vector-ops.c?rev=128381&r1=128380&r2=128381&view=diff
==============================================================================
--- cfe/trunk/test/Sema/vector-ops.c (original)
+++ cfe/trunk/test/Sema/vector-ops.c Sun Mar 27 10:36:07 2011
@@ -12,6 +12,9 @@
   (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];





More information about the cfe-commits mailing list