[cfe-commits] r74983 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp lib/Sema/SemaExpr.cpp test/CodeGen/ext-vector.c test/Sema/exprs.c
Chris Lattner
sabre at nondot.org
Tue Jul 7 18:08:04 PDT 2009
Author: lattner
Date: Tue Jul 7 20:08:03 2009
New Revision: 74983
URL: http://llvm.org/viewvc/llvm-project?rev=74983&view=rev
Log:
reimplement vector comparisons as [fi]cmp+sext instead of using v[if]cmp.
Also, enable them in sema so that they are tested, and now that the x86 backend
has stablized.
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGen/ext-vector.c
cfe/trunk/test/Sema/exprs.c
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=74983&r1=74982&r2=74983&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Jul 7 20:08:03 2009
@@ -49,7 +49,6 @@
CodeGenFunction &CGF;
CGBuilderTy &Builder;
bool IgnoreResultAssign;
-
public:
ScalarExprEmitter(CodeGenFunction &cgf, bool ira=false)
@@ -61,8 +60,10 @@
//===--------------------------------------------------------------------===//
bool TestAndClearIgnoreResultAssign() {
- bool I = IgnoreResultAssign; IgnoreResultAssign = false;
- return I; }
+ bool I = IgnoreResultAssign;
+ IgnoreResultAssign = false;
+ return I;
+ }
const llvm::Type *ConvertType(QualType T) { return CGF.ConvertType(T); }
LValue EmitLValue(const Expr *E) { return CGF.EmitLValue(E); }
@@ -1181,7 +1182,7 @@
TestAndClearIgnoreResultAssign();
Value *Result;
QualType LHSTy = E->getLHS()->getType();
- if (!LHSTy->isAnyComplexType() && !LHSTy->isVectorType()) {
+ if (!LHSTy->isAnyComplexType()) {
Value *LHS = Visit(E->getLHS());
Value *RHS = Visit(E->getRHS());
@@ -1196,22 +1197,12 @@
Result = Builder.CreateICmp((llvm::ICmpInst::Predicate)UICmpOpc,
LHS, RHS, "cmp");
}
- } else if (LHSTy->isVectorType()) {
- Value *LHS = Visit(E->getLHS());
- Value *RHS = Visit(E->getRHS());
+
+ // If this is a vector comparison, sign extend the result to the appropriate
+ // vector integer type and return it (don't convert to bool).
+ if (LHSTy->isVectorType())
+ return Builder.CreateSExt(Result, ConvertType(E->getType()), "sext");
- if (LHS->getType()->isFPOrFPVector()) {
- Result = Builder.CreateVFCmp((llvm::CmpInst::Predicate)FCmpOpc,
- LHS, RHS, "cmp");
- } else if (LHSTy->isUnsignedIntegerType()) {
- Result = Builder.CreateVICmp((llvm::CmpInst::Predicate)UICmpOpc,
- LHS, RHS, "cmp");
- } else {
- // Signed integers and pointers.
- Result = Builder.CreateVICmp((llvm::CmpInst::Predicate)SICmpOpc,
- LHS, RHS, "cmp");
- }
- return Result;
} else {
// Complex Comparison: can only be an equality comparison.
CodeGenFunction::ComplexPairTy LHS = CGF.EmitComplexExpr(E->getLHS());
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=74983&r1=74982&r2=74983&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jul 7 20:08:03 2009
@@ -4305,14 +4305,6 @@
CheckFloatComparison(Loc,lex,rex);
}
- // FIXME: Vector compare support in the LLVM backend is not fully reliable,
- // just reject all vector comparisons for now.
- if (1) {
- Diag(Loc, diag::err_typecheck_vector_comparison)
- << lType << rType << lex->getSourceRange() << rex->getSourceRange();
- return QualType();
- }
-
// 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.
Modified: cfe/trunk/test/CodeGen/ext-vector.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ext-vector.c?rev=74983&r1=74982&r2=74983&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/ext-vector.c (original)
+++ cfe/trunk/test/CodeGen/ext-vector.c Tue Jul 7 20:08:03 2009
@@ -115,9 +115,7 @@
a /= c;
a %= c;
- // Vector comparisons can sometimes crash the x86 backend: rdar://6326239,
- // reject them until the implementation is stable.
-#if 0
+ // Vector comparisons.
int4 cmp;
cmp = a < b;
cmp = a <= b;
@@ -125,5 +123,4 @@
cmp = a >= b;
cmp = a == b;
cmp = a != b;
-#endif
}
Modified: cfe/trunk/test/Sema/exprs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/exprs.c?rev=74983&r1=74982&r2=74983&view=diff
==============================================================================
--- cfe/trunk/test/Sema/exprs.c (original)
+++ cfe/trunk/test/Sema/exprs.c Tue Jul 7 20:08:03 2009
@@ -94,15 +94,12 @@
P = ^(){}; // expected-error {{blocks support disabled - compile with -fblocks}}
}
-
-// rdar://6326239 - Vector comparisons are not fully trusted yet, until the
-// backend is known to work, just unconditionally reject them.
void test14() {
typedef long long __m64 __attribute__((__vector_size__(8)));
typedef short __v4hi __attribute__((__vector_size__(8)));
+ // Ok.
__v4hi a;
- __m64 mask = (__m64)((__v4hi)a > // expected-error {{comparison of vector types ('__v4hi' and '__v4hi') not supported yet}}
- (__v4hi)a);
+ __m64 mask = (__m64)((__v4hi)a > (__v4hi)a);
}
More information about the cfe-commits
mailing list