AltiVec vector comparison logic now affect only vectors of fundamental AltiVec vector types. It fixes bug 9347.

llvm-svn: 128381
This commit is contained in:
Anton Yartsev 2011-03-27 15:36:07 +00:00
parent 1f90da127f
commit 530deb9a39
3 changed files with 13 additions and 6 deletions

View 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;

View File

@ -7277,14 +7277,16 @@ QualType Sema::CheckVectorCompareOperands(Expr *&lex, Expr *&rex,
if (vType.isNull())
return vType;
// If AltiVec, the comparison results in a numeric type, i.e.
// bool for C++, int for C
if (getLangOptions().AltiVec)
return Context.getLogicalOperationType();
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 (lType->getAs<VectorType>()->getVectorKind() == VectorType::AltiVecVector
&& rType->getAs<VectorType>()->getVectorKind() ==
VectorType::AltiVecVector)
return Context.getLogicalOperationType();
// 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.

View 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];