summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
author@raghesh (Raghesh Aloor) <raghesh.a@gmail.com>2020-01-09 10:52:39 -0500
committerSanjay Patel <spatel@rotateright.com>2020-01-09 10:52:39 -0500
commit6c04ef472a8739a60a7935f77edfbacd2f50eb73 (patch)
tree535979b6af34ab81a13e97d292ee1c9fbafa9876 /llvm/lib
parent0fa8f701ccf6f29544394b358f38b748e3f7ab24 (diff)
downloadbcm5719-llvm-6c04ef472a8739a60a7935f77edfbacd2f50eb73.tar.gz
bcm5719-llvm-6c04ef472a8739a60a7935f77edfbacd2f50eb73.zip
[InstCombine] Z / (1.0 / Y) => (Y * Z)
This is a special case of Z / (X / Y) => (Y * Z) / X, with X = 1.0. The m_OneUse check is avoided because even in the case of the multiple uses for 1.0/Y, the number of instructions remain the same and a division is replaced by a multiplication. Differential Revision: https://reviews.llvm.org/D72319
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index f7b39d98d49..2774e46151f 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -1239,6 +1239,14 @@ Instruction *InstCombiner::visitFDiv(BinaryOperator &I) {
Value *YZ = Builder.CreateFMulFMF(Y, Op0, &I);
return BinaryOperator::CreateFDivFMF(YZ, X, &I);
}
+ // Z / (1.0 / Y) => (Y * Z)
+ //
+ // This is a special case of Z / (X / Y) => (Y * Z) / X, with X = 1.0. The
+ // m_OneUse check is avoided because even in the case of the multiple uses
+ // for 1.0/Y, the number of instructions remain the same and a division is
+ // replaced by a multiplication.
+ if (match(Op1, m_FDiv(m_SpecificFP(1.0), m_Value(Y))))
+ return BinaryOperator::CreateFMulFMF(Y, Op0, &I);
}
if (I.hasAllowReassoc() && Op0->hasOneUse() && Op1->hasOneUse()) {
OpenPOWER on IntegriCloud