summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-02-14 17:16:33 +0000
committerSanjay Patel <spatel@rotateright.com>2018-02-14 17:16:33 +0000
commit5df4d8892fd5670fd31098d57af148a7fccceb07 (patch)
tree0b4acbc634d7b1c03b3999d7d62304c403b91f64 /llvm/lib
parent58dab856f7536c6d040d39393c2f7af9c931dd69 (diff)
downloadbcm5719-llvm-5df4d8892fd5670fd31098d57af148a7fccceb07.tar.gz
bcm5719-llvm-5df4d8892fd5670fd31098d57af148a7fccceb07.zip
[InstCombine] simplify isFMulOrFDivWithConstant(); NFCI
llvm-svn: 325142
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index e853a7bb64d..4cc2cbc493f 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -507,22 +507,14 @@ static bool isNormalFp(Constant *C) {
return isa<ConstantFP>(C) && cast<ConstantFP>(C)->getValueAPF().isNormal();
}
-/// Helper function of InstCombiner::visitFMul(BinaryOperator(). It returns
-/// true iff the given value is FMul or FDiv with one and only one operand
-/// being a normal constant (i.e. not Zero/NaN/Infinity).
+/// Helper function of InstCombiner::visitFMul(). Return true iff the given
+/// value is FMul or FDiv with one and only one operand being a finite-non-zero
+/// constant (i.e. not Zero/NaN/Infinity).
static bool isFMulOrFDivWithConstant(Value *V) {
- Instruction *I = dyn_cast<Instruction>(V);
- if (!I || (I->getOpcode() != Instruction::FMul &&
- I->getOpcode() != Instruction::FDiv))
- return false;
-
- Constant *C0 = dyn_cast<Constant>(I->getOperand(0));
- Constant *C1 = dyn_cast<Constant>(I->getOperand(1));
-
- if (C0 && C1)
- return false;
-
- return (C0 && isFiniteNonZeroFp(C0)) || (C1 && isFiniteNonZeroFp(C1));
+ Constant *C;
+ return (match(V, m_FMul(m_Value(), m_Constant(C))) ||
+ match(V, m_FDiv(m_Value(), m_Constant(C))) ||
+ match(V, m_FDiv(m_Constant(C), m_Value()))) && isFiniteNonZeroFp(C);
}
/// foldFMulConst() is a helper routine of InstCombiner::visitFMul().
OpenPOWER on IntegriCloud