diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-07-08 01:08:03 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-07-08 01:08:03 +0000 |
| commit | 2a7deb64c0fe77947bed52fc7044d2b1c0b4ab5b (patch) | |
| tree | 8184613057345e8a511bb3a962b50b61be37f402 /clang/lib/CodeGen/CGExprScalar.cpp | |
| parent | d41531a2c0e820a67fd0bb5af03bbd3518edb556 (diff) | |
| download | bcm5719-llvm-2a7deb64c0fe77947bed52fc7044d2b1c0b4ab5b.tar.gz bcm5719-llvm-2a7deb64c0fe77947bed52fc7044d2b1c0b4ab5b.zip | |
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.
llvm-svn: 74983
Diffstat (limited to 'clang/lib/CodeGen/CGExprScalar.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 2af0639f5ce..161cd574180 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -49,7 +49,6 @@ class VISIBILITY_HIDDEN ScalarExprEmitter CodeGenFunction &CGF; CGBuilderTy &Builder; bool IgnoreResultAssign; - public: ScalarExprEmitter(CodeGenFunction &cgf, bool ira=false) @@ -61,8 +60,10 @@ public: //===--------------------------------------------------------------------===// 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 @@ Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc, 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 @@ Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc, 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()); |

