diff options
author | Justin Bogner <mail@justinbogner.com> | 2016-04-26 22:22:18 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2016-04-26 22:22:18 +0000 |
commit | 7fd37fa92dc3c9c4e1d59e48980366566e292c37 (patch) | |
tree | 694fe68b1410b9451d2319ea723b39220e0a7c62 /lib/Transforms/Scalar/Reassociate.cpp | |
parent | 7f3fd5dcbde0e35cb378739e6afc10bd0b6148a3 (diff) |
Reassociate: Simplify using lambdas. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267614 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/Reassociate.cpp')
-rw-r--r-- | lib/Transforms/Scalar/Reassociate.cpp | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index 5e9a0b54861..cf124c8c67a 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/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 |