[llvm] MachineBlockPlacement: Add tolerance to comparisons (PR #67197)

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 3 15:23:48 PDT 2023


MatzeB wrote:

Thanks for the feedback. I contemplated the comments about this not being a partial weak ordering and there are indeed cases where picking the "best" candidate out of a list will give different results based on the list order which isn't desirable. So I reworked the approach to perform a two-pass algorithm: We first search for the biggest frequency (without any tolerances) and then in a 2nd pass check all blocks that are almost equal to the biggest frequency. This also means that I know have an `almostEqual` function (and no longer have less/greaterWithTolerance).

I also think that this approach is slightly better than pre-rounding BFI numbers, as for pre-rounding we still may have two candidate blocks that had very similar frequency but happened to be at the border where one gets rounded up and the other rounded down, which doesn't happen with this approach.


https://github.com/llvm/llvm-project/pull/67197


More information about the llvm-commits mailing list