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

Rahman Lavaee via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 5 14:27:07 PDT 2023


rlavaee 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.

I like the new approach. Some general comments:

1. Do you have any idea why this impacts so many of the block ordering tests?
2. Do you intend to limit this functionality to the baseline ordering only (i.e, Does applyExtTsp() remain sensitive to small variations)? 
3. Is this functionality supposed to be controlled by a flag?

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


More information about the llvm-commits mailing list