summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/Reassociate.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2016-04-26 23:32:00 +0000
committerJustin Bogner <mail@justinbogner.com>2016-04-26 23:32:00 +0000
commitcb8a21c88e801d2f56b90d01b1a2e3be07bb1663 (patch)
tree4c1d7162190281c6efc2f7c95f9011e9884a66b5 /llvm/lib/Transforms/Scalar/Reassociate.cpp
parentf105db4fc3541b9df9f30040d644a5b32d6d3cf2 (diff)
downloadbcm5719-llvm-cb8a21c88e801d2f56b90d01b1a2e3be07bb1663.tar.gz
bcm5719-llvm-cb8a21c88e801d2f56b90d01b1a2e3be07bb1663.zip
Reassociate: Convert another functor into a lambda. NFC
Also move the explanatory comment with it. llvm-svn: 267628
Diffstat (limited to 'llvm/lib/Transforms/Scalar/Reassociate.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/Reassociate.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp
index cf124c8c67a..417546b0839 100644
--- a/llvm/lib/Transforms/Scalar/Reassociate.cpp
+++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp
@@ -106,20 +106,6 @@ namespace {
void Invalidate() { SymbolicPart = OrigVal = nullptr; }
void setSymbolicRank(unsigned R) { SymbolicRank = R; }
- // Sort the XorOpnd-Pointer in ascending order of symbolic-value-rank.
- // The purpose is twofold:
- // 1) Cluster together the operands sharing the same symbolic-value.
- // 2) Operand having smaller symbolic-value-rank is permuted earlier, which
- // could potentially shorten crital path, and expose more loop-invariants.
- // Note that values' rank are basically defined in RPO order (FIXME).
- // So, if Rank(X) < Rank(Y) < Rank(Z), it means X is defined earlier
- // than Y which is defined earlier than Z. Permute "x | 1", "Y & 2",
- // "z" in the order of X-Y-Z is better than any other orders.
- struct PtrSortFunctor {
- bool operator()(XorOpnd * const &LHS, XorOpnd * const &RHS) {
- return LHS->getSymbolicRank() < RHS->getSymbolicRank();
- }
- };
private:
Value *OrigVal;
Value *SymbolicPart;
@@ -1391,7 +1377,19 @@ Value *Reassociate::OptimizeXor(Instruction *I,
// the same symbolic value cluster together. For instance, the input operand
// sequence ("x | 123", "y & 456", "x & 789") will be sorted into:
// ("x | 123", "x & 789", "y & 456").
- std::stable_sort(OpndPtrs.begin(), OpndPtrs.end(), XorOpnd::PtrSortFunctor());
+ //
+ // The purpose is twofold:
+ // 1) Cluster together the operands sharing the same symbolic-value.
+ // 2) Operand having smaller symbolic-value-rank is permuted earlier, which
+ // could potentially shorten crital path, and expose more loop-invariants.
+ // Note that values' rank are basically defined in RPO order (FIXME).
+ // So, if Rank(X) < Rank(Y) < Rank(Z), it means X is defined earlier
+ // than Y which is defined earlier than Z. Permute "x | 1", "Y & 2",
+ // "z" in the order of X-Y-Z is better than any other orders.
+ std::stable_sort(OpndPtrs.begin(), OpndPtrs.end(),
+ [](XorOpnd *LHS, XorOpnd *RHS) {
+ return LHS->getSymbolicRank() < RHS->getSymbolicRank();
+ });
// Step 3: Combine adjacent operands
XorOpnd *PrevOpnd = nullptr;
OpenPOWER on IntegriCloud