From: Eli Friedman Date: Wed, 22 Jul 2009 06:07:16 +0000 (+0000) Subject: Make vectorized floating-point comparisons work without crashing. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1360d4ad9045056d646c118344c7c5148aea4a52;p=clang Make vectorized floating-point comparisons work without crashing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76726 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index e58693a8d6..4d31f99e3a 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -1215,7 +1215,7 @@ Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc, Value *LHS = Visit(E->getLHS()); Value *RHS = Visit(E->getRHS()); - if (LHS->getType()->isFloatingPoint()) { + if (LHS->getType()->isFPOrFPVector()) { Result = Builder.CreateFCmp((llvm::CmpInst::Predicate)FCmpOpc, LHS, RHS, "cmp"); } else if (LHSTy->isSignedIntegerType()) { diff --git a/test/CodeGen/ext-vector.c b/test/CodeGen/ext-vector.c index 4739a661cc..6a246db635 100644 --- a/test/CodeGen/ext-vector.c +++ b/test/CodeGen/ext-vector.c @@ -124,3 +124,17 @@ void test7(int4 *ap, int4 *bp, int c) { cmp = a == b; cmp = a != b; } + +void test8(float4 *ap, float4 *bp, int c) { + float4 a = *ap; + float4 b = *bp; + + // Vector comparisons. + int4 cmp; + cmp = a < b; + cmp = a <= b; + cmp = a < b; + cmp = a >= b; + cmp = a == b; + cmp = a != b; +}