[InstCombine] simplify code for X * -1.0 --> -X; NFC
I've added random FMF to one of the tests to show those are propagated.
llvm-svn: 326377
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index f79e33f..b445c33 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -563,13 +563,9 @@
if (match(Op0, m_FNeg(m_Value(X))))
return BinaryOperator::CreateFMulFMF(X, ConstantExpr::getFNeg(C), &I);
- // (fmul X, -1.0) --> (fsub -0.0, X)
- if (match(C, m_SpecificFP(-1.0))) {
- Constant *NegZero = ConstantFP::getNegativeZero(Op1->getType());
- Instruction *RI = BinaryOperator::CreateFSub(NegZero, Op0);
- RI->copyFastMathFlags(&I);
- return RI;
- }
+ // X * -1.0 --> -X
+ if (match(C, m_SpecificFP(-1.0)))
+ return BinaryOperator::CreateFNegFMF(Op0, &I);
if (AllowReassociate && C->isFiniteNonZeroFP()) {
// Let MDC denote an expression in one of these forms: