llvm.org GIT mirror
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).
 52 52 NumClasses = 0; 53 53 } 54 54 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); 59 59 60 60 /// findLeader - Compute the leader of a's equivalence class. This is the 61 61 /// smallest member of the class.
 28 28 EC.push_back(EC.size()); 29 29 } 30 30 31 void IntEqClasses::join(unsigned a, unsigned b) {⏎ 31 unsigned IntEqClasses::join(unsigned a, unsigned b) {⏎ 32 32 assert(NumClasses == 0 && "join() called after compress()."); 33 33 unsigned eca = EC[a]; 34 34 unsigned ecb = EC[b]; 40 40 EC[b] = eca, b = ecb, ecb = EC[b]; 41 41 else 42 42 EC[a] = ecb, a = eca, eca = EC[a]; 43 44 return eca; 43 45 } 44 46 45 47 unsigned IntEqClasses::findLeader(unsigned a) const {