]> granicus.if.org Git - clang/commitdiff
Make vectorized floating-point comparisons work without crashing.
authorEli Friedman <eli.friedman@gmail.com>
Wed, 22 Jul 2009 06:07:16 +0000 (06:07 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Wed, 22 Jul 2009 06:07:16 +0000 (06:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76726 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprScalar.cpp
test/CodeGen/ext-vector.c

index e58693a8d66cb76b566280c6d7a6ae7abf13fee6..4d31f99e3a2e69b1a6945b7ca7db1f3e275521fb 100644 (file)
@@ -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()) {
index 4739a661cc04a28f2803afb0b980cc2a6750d9da..6a246db63515ddc20e811a4bb756d23ad58131aa 100644 (file)
@@ -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;
+}