[llvm] r362904 - [InstSimplify] reduce code duplication for fcmp folds; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 9 06:58:47 PDT 2019


Author: spatel
Date: Sun Jun  9 06:58:46 2019
New Revision: 362904

URL: http://llvm.org/viewvc/llvm-project?rev=362904&view=rev
Log:
[InstSimplify] reduce code duplication for fcmp folds; NFC

Modified:
    llvm/trunk/lib/Analysis/InstructionSimplify.cpp

Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=362904&r1=362903&r2=362904&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Sun Jun  9 06:58:46 2019
@@ -3477,22 +3477,19 @@ static Value *SimplifyFCmpInst(unsigned
   if (match(RHS, m_AnyZeroFP())) {
     switch (Pred) {
     case FCmpInst::FCMP_OGE:
-      if ((FMF.noNaNs() || isKnownNeverNaN(LHS, Q.TLI)) &&
-          CannotBeOrderedLessThanZero(LHS, Q.TLI))
-        return getTrue(RetTy);
-      break;
-    case FCmpInst::FCMP_UGE:
-      if (CannotBeOrderedLessThanZero(LHS, Q.TLI))
-        return getTrue(RetTy);
-      break;
     case FCmpInst::FCMP_ULT:
+      // Positive or zero X >= 0.0 --> true
+      // Positive or zero X <  0.0 --> false
       if ((FMF.noNaNs() || isKnownNeverNaN(LHS, Q.TLI)) &&
           CannotBeOrderedLessThanZero(LHS, Q.TLI))
-        return getFalse(RetTy);
+        return Pred == FCmpInst::FCMP_OGE ? getTrue(RetTy) : getFalse(RetTy);
       break;
+    case FCmpInst::FCMP_UGE:
     case FCmpInst::FCMP_OLT:
+      // Positive or zero or nan X >= 0.0 --> true
+      // Positive or zero or nan X <  0.0 --> false
       if (CannotBeOrderedLessThanZero(LHS, Q.TLI))
-        return getFalse(RetTy);
+        return Pred == FCmpInst::FCMP_UGE ? getTrue(RetTy) : getFalse(RetTy);
       break;
     default:
       break;




More information about the llvm-commits mailing list