summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/Reassociate.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2016-04-26 22:22:18 +0000
committerJustin Bogner <mail@justinbogner.com>2016-04-26 22:22:18 +0000
commit90744d215b4347ecb546ce55102a82da2d7470c2 (patch)
tree99ff62da5a5d113df6824a22a5b164dc8ada44d7 /llvm/lib/Transforms/Scalar/Reassociate.cpp
parent1763dc44b9a450c42236e84cc9b919d0445860c8 (diff)
downloadbcm5719-llvm-90744d215b4347ecb546ce55102a82da2d7470c2.tar.gz
bcm5719-llvm-90744d215b4347ecb546ce55102a82da2d7470c2.zip
Reassociate: Simplify using lambdas. NFC
llvm-svn: 267614
Diffstat (limited to 'llvm/lib/Transforms/Scalar/Reassociate.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/Reassociate.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp
index 5e9a0b54861..cf124c8c67a 100644
--- a/llvm/lib/Transforms/Scalar/Reassociate.cpp
+++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp
@@ -81,22 +81,7 @@ namespace {
struct Factor {
Value *Base;
unsigned Power;
-
Factor(Value *Base, unsigned Power) : Base(Base), Power(Power) {}
-
- /// \brief Sort factors in descending order by their power.
- struct PowerDescendingSorter {
- bool operator()(const Factor &LHS, const Factor &RHS) {
- return LHS.Power > RHS.Power;
- }
- };
-
- /// \brief Compare factors for equal powers.
- struct PowerEqual {
- bool operator()(const Factor &LHS, const Factor &RHS) {
- return LHS.Power == RHS.Power;
- }
- };
};
/// Utility class representing a non-constant Xor-operand. We classify
@@ -1764,7 +1749,10 @@ bool Reassociate::collectMultiplyFactors(SmallVectorImpl<ValueEntry> &Ops,
// below our mininum of '4'.
assert(FactorPowerSum >= 4);
- std::stable_sort(Factors.begin(), Factors.end(), Factor::PowerDescendingSorter());
+ std::stable_sort(Factors.begin(), Factors.end(),
+ [](const Factor &LHS, const Factor &RHS) {
+ return LHS.Power > RHS.Power;
+ });
return true;
}
@@ -1823,7 +1811,9 @@ Value *Reassociate::buildMinimalMultiplyDAG(IRBuilder<> &Builder,
// Unique factors with equal powers -- we've folded them into the first one's
// base.
Factors.erase(std::unique(Factors.begin(), Factors.end(),
- Factor::PowerEqual()),
+ [](const Factor &LHS, const Factor &RHS) {
+ return LHS.Power == RHS.Power;
+ }),
Factors.end());
// Iteratively collect the base of each factor with an add power into the
OpenPOWER on IntegriCloud