[llvm] r312421 - [InstCombine] replace unnecessary fcmp fold with assert

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 2 11:10:29 PDT 2017


Author: spatel
Date: Sat Sep  2 11:10:29 2017
New Revision: 312421

URL: http://llvm.org/viewvc/llvm-project?rev=312421&view=rev
Log:
[InstCombine] replace unnecessary fcmp fold with assert

See https://reviews.llvm.org/rL312411 for related InstSimplify tests.

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=312421&r1=312420&r2=312421&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Sat Sep  2 11:10:29 2017
@@ -941,12 +941,9 @@ Value *InstCombiner::foldLogicOfFCmps(FC
     auto *LHSC = dyn_cast<ConstantFP>(LHS1);
     auto *RHSC = dyn_cast<ConstantFP>(RHS1);
     if (LHSC && RHSC) {
-      // If either of the constants are nans, then the whole thing returns
-      // true or false.
-      if (LHSC->getValueAPF().isNaN() || RHSC->getValueAPF().isNaN())
-        return IsAnd ? Builder.getFalse() : Builder.getTrue();
-
-      // Otherwise, no need to compare the two constants. Compare the rest:
+      assert(!LHSC->getValueAPF().isNaN() && !RHSC->getValueAPF().isNaN() &&
+             "Failed to simplify fcmp ord/uno with NAN operand");
+      // Ignore the constants because they can't be NANs:
       // (fcmp ord x, c) & (fcmp ord y, c)  -> (fcmp ord x, y)
       // (fcmp uno x, c) & (fcmp uno y, c)  -> (fcmp uno x, y)
       return Builder.CreateFCmp(PredL, LHS0, RHS0);




More information about the llvm-commits mailing list