diff options
| author | Tanya Lattner <tonic@nondot.org> | 2011-10-17 21:00:38 +0000 |
|---|---|---|
| committer | Tanya Lattner <tonic@nondot.org> | 2011-10-17 21:00:38 +0000 |
| commit | 49b38413985c5e74790d9f6ff9459c82773e932f (patch) | |
| tree | 5f7a2fbddaf0d4dbe3f7550d0c1e1aca53362558 /clang/lib/Sema/SemaExpr.cpp | |
| parent | 502d2eee0993186a6eb4a9c8647a0e44d9a76e6a (diff) | |
| download | bcm5719-llvm-49b38413985c5e74790d9f6ff9459c82773e932f.tar.gz bcm5719-llvm-49b38413985c5e74790d9f6ff9459c82773e932f.zip | |
The comparison of two vectors should return a signed result. hasIntegerRepresentation() used to always return false for vectors, but since it was changed, it also
changed the return type of a compare of two unsigned vectors to be unsigned. This patch removes the check for hasIntegerRepresentation since its not needed and returns the appropriate signed type.
I added a new test case and updated exisiting test cases that assumed an unsigned result.
llvm-svn: 142250
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 346228f6b7b..d3dec96d44c 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -6760,19 +6760,19 @@ QualType Sema::CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, CheckFloatComparison(Loc, LHS.get(), RHS.get()); } - // Return the type for the comparison, which is the same as vector type for - // integer vectors, or an integer type of identical size and number of - // elements for floating point vectors. - if (LHSType->hasIntegerRepresentation()) - return LHSType; - + // Return a signed type that is of identical size and number of elements. + // For floating point vectors, return an integer type of identical size + // and number of elements. const VectorType *VTy = LHSType->getAs<VectorType>(); unsigned TypeSize = Context.getTypeSize(VTy->getElementType()); - if (TypeSize == Context.getTypeSize(Context.IntTy)) + if (TypeSize == Context.getTypeSize(Context.CharTy)) + return Context.getExtVectorType(Context.CharTy, VTy->getNumElements()); + else if (TypeSize == Context.getTypeSize(Context.ShortTy)) + return Context.getExtVectorType(Context.ShortTy, VTy->getNumElements()); + else if (TypeSize == Context.getTypeSize(Context.IntTy)) return Context.getExtVectorType(Context.IntTy, VTy->getNumElements()); - if (TypeSize == Context.getTypeSize(Context.LongTy)) + else if (TypeSize == Context.getTypeSize(Context.LongTy)) return Context.getExtVectorType(Context.LongTy, VTy->getNumElements()); - assert(TypeSize == Context.getTypeSize(Context.LongLongTy) && "Unhandled vector element size in vector compare"); return Context.getExtVectorType(Context.LongLongTy, VTy->getNumElements()); |

