summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGExprScalar.cpp
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2008-07-25 20:16:05 +0000
committerNate Begeman <natebegeman@mac.com>2008-07-25 20:16:05 +0000
commitfe79ca2ab92918a40155cfcee32ac8b52a0419ff (patch)
tree25856bb4b5dfeceff4c3cd15d3c88d268d5f628e /clang/lib/CodeGen/CGExprScalar.cpp
parente7f45b29779c81aa2669edf0ff6b0c97c7ce8017 (diff)
Generate vector compares in codegen
llvm-svn: 54048
Diffstat (limited to 'clang/lib/CodeGen/CGExprScalar.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprScalar.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index 5a75e5366920..154e2628f645 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/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());