[PATCH] D24143: Fix incorrect folding of an ordered fcmp with a vector of all NaN.

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 2 07:56:03 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL280488: [instsimplify] Fix incorrect folding of an ordered fcmp with a vector of all… (authored by adibiagio).

Changed prior to commit:
  https://reviews.llvm.org/D24143?vs=70024&id=70166#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24143

Files:
  llvm/trunk/lib/Analysis/InstructionSimplify.cpp
  llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll

Index: llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll
===================================================================
--- llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll
+++ llvm/trunk/test/Transforms/InstSimplify/floating-point-compare.ll
@@ -123,3 +123,11 @@
   %cmp = fcmp nnan ord double %in1, %in2
   ret i1 %cmp
 }
+
+define <2 x i1> @orderedCompareWithNaNVector(<2 x double> %A) {
+; CHECK-LABEL: @orderedCompareWithNaNVector(
+; CHECK: ret <2 x i1> zeroinitializer
+  %cmp = fcmp olt <2 x double> %A, <double 0xFFFFFFFFFFFFFFFF, double 0xFFFFFFFFFFFFFFFF>
+  ret <2 x i1> %cmp
+}
+
Index: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp
@@ -3235,7 +3235,7 @@
     // If the constant is a nan, see if we can fold the comparison based on it.
     if (CFP->getValueAPF().isNaN()) {
       if (FCmpInst::isOrdered(Pred)) // True "if ordered and foo"
-        return ConstantInt::getFalse(CFP->getContext());
+        return ConstantInt::get(GetCompareTy(LHS), 0);
       assert(FCmpInst::isUnordered(Pred) &&
              "Comparison must be either ordered or unordered!");
       // True if unordered.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24143.70166.patch
Type: text/x-patch
Size: 1321 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160902/92c85812/attachment.bin>


More information about the llvm-commits mailing list