[llvm] r319043 - [InstSimplify] use m_APFloat to simplify fcmp folds; NFCI
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 27 08:37:09 PST 2017
Author: spatel
Date: Mon Nov 27 08:37:09 2017
New Revision: 319043
URL: http://llvm.org/viewvc/llvm-project?rev=319043&view=rev
Log:
[InstSimplify] use m_APFloat to simplify fcmp folds; NFCI
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=319043&r1=319042&r2=319043&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Mon Nov 27 08:37:09 2017
@@ -3326,17 +3326,11 @@ static Value *SimplifyFCmpInst(unsigned
return getFalse(RetTy);
}
- // Handle fcmp with constant RHS
- const ConstantFP *CFP = nullptr;
- if (const auto *RHSC = dyn_cast<Constant>(RHS)) {
- if (RHS->getType()->isVectorTy())
- CFP = dyn_cast_or_null<ConstantFP>(RHSC->getSplatValue());
- else
- CFP = dyn_cast<ConstantFP>(RHSC);
- }
- if (CFP) {
+ // Handle fcmp with constant RHS.
+ const APFloat *C;
+ if (match(RHS, m_APFloat(C))) {
// If the constant is a nan, see if we can fold the comparison based on it.
- if (CFP->getValueAPF().isNaN()) {
+ if (C->isNaN()) {
if (FCmpInst::isOrdered(Pred)) // True "if ordered and foo"
return getFalse(RetTy);
assert(FCmpInst::isUnordered(Pred) &&
@@ -3345,8 +3339,8 @@ static Value *SimplifyFCmpInst(unsigned
return getTrue(RetTy);
}
// Check whether the constant is an infinity.
- if (CFP->getValueAPF().isInfinity()) {
- if (CFP->getValueAPF().isNegative()) {
+ if (C->isInfinity()) {
+ if (C->isNegative()) {
switch (Pred) {
case FCmpInst::FCMP_OLT:
// No value is ordered and less than negative infinity.
@@ -3370,7 +3364,7 @@ static Value *SimplifyFCmpInst(unsigned
}
}
}
- if (CFP->getValueAPF().isZero()) {
+ if (C->isZero()) {
switch (Pred) {
case FCmpInst::FCMP_UGE:
if (CannotBeOrderedLessThanZero(LHS, Q.TLI))
More information about the llvm-commits
mailing list