mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-06 20:37:05 +00:00
Reassociate: Simplify using lambdas. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267614 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7f3fd5dcbd
commit
7fd37fa92d
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user