diff options
-rw-r--r-- | lib/CodeGen/CGExprScalar.cpp | 8 | ||||
-rw-r--r-- | test/CodeGen/pointer-cmp-type.c | 3 |
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 9daa21eb34..fc8639dbf2 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -917,12 +917,12 @@ Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc, if (LHS->getType()->isFloatingPoint()) { Result = Builder.CreateFCmp((llvm::FCmpInst::Predicate)FCmpOpc, LHS, RHS, "cmp"); - } else if (LHSTy->isUnsignedIntegerType()) { - Result = Builder.CreateICmp((llvm::ICmpInst::Predicate)UICmpOpc, + } else if (LHSTy->isSignedIntegerType()) { + Result = Builder.CreateICmp((llvm::ICmpInst::Predicate)SICmpOpc, LHS, RHS, "cmp"); } else { - // Signed integers and pointers. - Result = Builder.CreateICmp((llvm::ICmpInst::Predicate)SICmpOpc, + // Unsigned integers and pointers. + Result = Builder.CreateICmp((llvm::ICmpInst::Predicate)UICmpOpc, LHS, RHS, "cmp"); } } else { diff --git a/test/CodeGen/pointer-cmp-type.c b/test/CodeGen/pointer-cmp-type.c new file mode 100644 index 0000000000..02fc4c7675 --- /dev/null +++ b/test/CodeGen/pointer-cmp-type.c @@ -0,0 +1,3 @@ +// RUN: clang -emit-llvm %s -o - | grep "icmp ult" + +int a(char* a, char* b) {return a<b;} |