summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-02-28 22:30:04 +0000
committerSanjay Patel <spatel@rotateright.com>2018-02-28 22:30:04 +0000
commiteaf5a120edd4001874ae1c36469bf783d5c75488 (patch)
tree78de3b03e36dbd5c1cb919d73e613e5d60452026 /llvm/lib/Transforms
parent9ca064552a7c38798f763b64113ae74bf04a0b23 (diff)
downloadbcm5719-llvm-eaf5a120edd4001874ae1c36469bf783d5c75488.tar.gz
bcm5719-llvm-eaf5a120edd4001874ae1c36469bf783d5c75488.zip
[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
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index f79e33fe597..b445c33e88c 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -563,13 +563,9 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) {
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:
OpenPOWER on IntegriCloud