summaryrefslogtreecommitdiff
path: root/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2014-01-18 16:43:14 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2014-01-18 16:43:14 +0000
commit8e937c39bb389e9aeb92467b99e76373bf547bab (patch)
tree0abf27aeace1eb1ff1b92912ae00a16fdc1a5006 /lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
parentbedf842b78d00dc481a83edf7f1a3ca5f21a3805 (diff)
InstCombine: Make the (fmul X, -1.0) -> (fsub -0.0, X) transform handle vectors too.
PR18532. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199553 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineMulDivRem.cpp')
-rw-r--r--lib/Transforms/InstCombine/InstCombineMulDivRem.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index f61d82340b5..2fcd003bcbd 100644
--- a/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -425,17 +425,15 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) {
if (Instruction *NV = FoldOpIntoPhi(I))
return NV;
- ConstantFP *C = dyn_cast<ConstantFP>(Op1);
-
// (fmul X, -1.0) --> (fsub -0.0, X)
- if (C && C->isExactlyValue(-1.0)) {
- Instruction *RI = BinaryOperator::CreateFSub(
- ConstantFP::getNegativeZero(C->getType()),
- Op0);
+ if (match(Op1, m_SpecificFP(-1.0))) {
+ Constant *NegZero = ConstantFP::getNegativeZero(Op1->getType());
+ Instruction *RI = BinaryOperator::CreateFSub(NegZero, Op0);
RI->copyFastMathFlags(&I);
return RI;
}
+ ConstantFP *C = dyn_cast<ConstantFP>(Op1);
if (C && AllowReassociate && C->getValueAPF().isFiniteNonZero()) {
// Let MDC denote an expression in one of these forms:
// X * C, C/X, X/C, where C is a constant.