diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2017-11-27 16:37:09 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2017-11-27 16:37:09 +0000 |
| commit | 4ca9968155b6056749dfa792de5703f2a5d7d307 (patch) | |
| tree | b7da3e1f7e0bea18da2c4b86a587dd6fb1540f16 /llvm/lib | |
| parent | 1ea2f5e374e4b0801e9b576eced32b3f2d08d4c6 (diff) | |
| download | bcm5719-llvm-4ca9968155b6056749dfa792de5703f2a5d7d307.tar.gz bcm5719-llvm-4ca9968155b6056749dfa792de5703f2a5d7d307.zip | |
[InstSimplify] use m_APFloat to simplify fcmp folds; NFCI
llvm-svn: 319043
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 76af3dcd90e..6bed2f3a901 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -3326,17 +3326,11 @@ static Value *SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, 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 Predicate, Value *LHS, Value *RHS, 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 Predicate, Value *LHS, Value *RHS, } } } - if (CFP->getValueAPF().isZero()) { + if (C->isZero()) { switch (Pred) { case FCmpInst::FCMP_UGE: if (CannotBeOrderedLessThanZero(LHS, Q.TLI)) |

