[llvm] MachineBlockPlacement: Add tolerance to comparisons (PR #67197)
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 5 14:55:40 PDT 2023
================
@@ -93,6 +94,28 @@ class BlockFrequency {
return *this;
}
+ /// Returns true if `this` is greater than `other` and the magnitude of the
+ /// difference falls within the topmost `SignificantBits` of `this`.
+ ///
+ /// The formula is related to comparing a "relative change" to a threshold.
+ /// When choosing the threshold as a negative power-of-two things can be
+ /// computed cheaply:
+ /// with A = this->Frequency; B = Other.Frequency; T = SignificantBits
+ /// relative_change(A, B) = abs(A - B) / A
----------------
MatzeB wrote:
Well I thought that saving the `if` may be worth it for some callers, but you are right that it happened to produce extra complications with that `IsEHPad` logic here. I'll change it.
https://github.com/llvm/llvm-project/pull/67197
More information about the llvm-commits
mailing list