[llvm] r257130 - IntEqClasses: Let join() return the new leader
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 7 17:16:39 PST 2016
Author: matze
Date: Thu Jan 7 19:16:39 2016
New Revision: 257130
URL: http://llvm.org/viewvc/llvm-project?rev=257130&view=rev
Log:
IntEqClasses: Let join() return the new leader
The new leader is known anyway so we can return it for some micro
optimization in code where it is easy to pass along the result to the
next join().
Modified:
llvm/trunk/include/llvm/ADT/IntEqClasses.h
llvm/trunk/lib/Support/IntEqClasses.cpp
Modified: llvm/trunk/include/llvm/ADT/IntEqClasses.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/IntEqClasses.h?rev=257130&r1=257129&r2=257130&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/IntEqClasses.h (original)
+++ llvm/trunk/include/llvm/ADT/IntEqClasses.h Thu Jan 7 19:16:39 2016
@@ -53,10 +53,10 @@ public:
NumClasses = 0;
}
- /// join - Join the equivalence classes of a and b. After joining classes,
- /// findLeader(a) == findLeader(b).
- /// This requires an uncompressed map.
- void join(unsigned a, unsigned b);
+ /// Join the equivalence classes of a and b. After joining classes,
+ /// findLeader(a) == findLeader(b). This requires an uncompressed map.
+ /// Returns the new leader.
+ unsigned join(unsigned a, unsigned b);
/// findLeader - Compute the leader of a's equivalence class. This is the
/// smallest member of the class.
Modified: llvm/trunk/lib/Support/IntEqClasses.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/IntEqClasses.cpp?rev=257130&r1=257129&r2=257130&view=diff
==============================================================================
--- llvm/trunk/lib/Support/IntEqClasses.cpp (original)
+++ llvm/trunk/lib/Support/IntEqClasses.cpp Thu Jan 7 19:16:39 2016
@@ -29,7 +29,7 @@ void IntEqClasses::grow(unsigned N) {
EC.push_back(EC.size());
}
-void IntEqClasses::join(unsigned a, unsigned b) {
+unsigned IntEqClasses::join(unsigned a, unsigned b) {
assert(NumClasses == 0 && "join() called after compress().");
unsigned eca = EC[a];
unsigned ecb = EC[b];
@@ -41,6 +41,8 @@ void IntEqClasses::join(unsigned a, unsi
EC[b] = eca, b = ecb, ecb = EC[b];
else
EC[a] = ecb, a = eca, eca = EC[a];
+
+ return eca;
}
unsigned IntEqClasses::findLeader(unsigned a) const {
More information about the llvm-commits
mailing list