[PATCH] D158875: [ADT] Fix IntEqClasses::join to return the leader in all cases.
    Joshua Cranmer via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Wed Aug 30 07:28:03 PDT 2023
    
    
  
jcranmer-intel added inline comments.
================
Comment at: llvm/lib/Support/IntEqClasses.cpp:36-52
   // Update pointers while searching for the leaders, compressing the paths
   // incrementally. The larger leader will eventually be updated, joining the
   // classes.
   while (eca != ecb)
     if (eca < ecb) {
       EC[b] = eca;
       b = ecb;
----------------
MatzeB wrote:
> Not sure how this would affect worst-case complexity given `findLeader` does not do any path compression. How about this instead?
The changes I made wouldn't make the worst-case complexity any worse; it seems to me that it would work better to have `findLeader` do path compression instead (I further note that there appear to be no callers of `IntEqClasses::findLeader` in LLVM at present, so there's definitely no compile time regression here).
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158875/new/
https://reviews.llvm.org/D158875
    
    
More information about the llvm-commits
mailing list