llvm.org GIT mirror llvm / aaf3afc
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(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257130 91177308-0d34-0410-b5e6-96231b3b80d8 Matthias Braun 3 years ago
2 changed file(s) with 7 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
5252 NumClasses = 0;
5353 }
5454
55 /// join - Join the equivalence classes of a and b. After joining classes,
56 /// findLeader(a) == findLeader(b).
57 /// This requires an uncompressed map.
58 void join(unsigned a, unsigned b);
55 /// Join the equivalence classes of a and b. After joining classes,
56 /// findLeader(a) == findLeader(b). This requires an uncompressed map.
57 /// Returns the new leader.
58 unsigned join(unsigned a, unsigned b);
5959
6060 /// findLeader - Compute the leader of a's equivalence class. This is the
6161 /// smallest member of the class.
2828 EC.push_back(EC.size());
2929 }
3030
31 void IntEqClasses::join(unsigned a, unsigned b) {
31 unsigned IntEqClasses::join(unsigned a, unsigned b) {
3232 assert(NumClasses == 0 && "join() called after compress().");
3333 unsigned eca = EC[a];
3434 unsigned ecb = EC[b];
4040 EC[b] = eca, b = ecb, ecb = EC[b];
4141 else
4242 EC[a] = ecb, a = eca, eca = EC[a];
43
44 return eca;
4345 }
4446
4547 unsigned IntEqClasses::findLeader(unsigned a) const {