From: Nate Begeman Date: Fri, 25 Jul 2008 20:16:05 +0000 (+0000) Subject: Generate vector compares in codegen X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7a66d7b6c0d84f8c9c74c687a338cf3cf6b9c808;p=clang Generate vector compares in codegen git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54048 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 5a75e53669..154e2628f6 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -911,12 +911,12 @@ Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc, unsigned SICmpOpc, unsigned FCmpOpc) { Value *Result; QualType LHSTy = E->getLHS()->getType(); - if (!LHSTy->isAnyComplexType()) { + if (!LHSTy->isAnyComplexType() && !LHSTy->isVectorType()) { Value *LHS = Visit(E->getLHS()); Value *RHS = Visit(E->getRHS()); if (LHS->getType()->isFloatingPoint()) { - Result = Builder.CreateFCmp((llvm::FCmpInst::Predicate)FCmpOpc, + Result = Builder.CreateFCmp((llvm::CmpInst::Predicate)FCmpOpc, LHS, RHS, "cmp"); } else if (LHSTy->isSignedIntegerType()) { Result = Builder.CreateICmp((llvm::ICmpInst::Predicate)SICmpOpc, @@ -926,6 +926,22 @@ 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 (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());