[PATCH] D36963: Use sorting instead of a lot of stable_partitions for `ICF::segregate` function

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 23 15:57:17 PDT 2017


ruiu added a comment.

I took time to think about the algorithm and experimented your patch locally. First thing I notice is that this patch actually significantly improves the performance of ICF. Excellent job!

So, what I found is, I believe we can compare pointer values as you originally did, and that should produce fully reproducible outputs. That's because relative order in Chunks vector doesn't affect the result of our ICF algorithm. To see that, assume equivalence classes A, B, C and D. Also assume two Chunk vectors X and Y where X and Y contain sections whose equivalence classes are

  A, A, B, C, C, D, D, D

and

  B, A, A, D, D, D, C, C

respectively.

X will be processed in A, B, C, D order, and Y will be processed in B, A, D, C order. However, that order doesn't really matter because our algorithm only care about relative order in the same equivalence class.

Do you think my analysis is correct?


https://reviews.llvm.org/D36963





More information about the llvm-commits mailing list