[llvm] [PGO][NFC] Avoid floating-point block uniformity check (PR #206547)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 29 10:49:32 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-pgo
Author: Yaxun (Sam) Liu (yxsamliu)
<details>
<summary>Changes</summary>
Use an integer threshold when deciding whether a block is mostly uniform.
This keeps the 90% rule exact and avoids relying on floating-point arithmetic in profile merging.
---
Full diff: https://github.com/llvm/llvm-project/pull/206547.diff
1 Files Affected:
- (modified) llvm/lib/ProfileData/InstrProf.cpp (+2-2)
``````````diff
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 1124cbd95b185..1002c80af7801 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -962,8 +962,8 @@ void InstrProfRecord::computeBlockUniformity() {
for (size_t I = 0, E = Counts.size(); I < E; ++I) {
uint64_t TotalCount = Counts[I];
uint64_t UniformCount = UniformCounts[I];
- bool IsUniform =
- TotalCount == 0 || (double)UniformCount / TotalCount >= 0.9;
+ uint64_t MinUniformCount = TotalCount - TotalCount / 10;
+ bool IsUniform = UniformCount >= MinUniformCount;
if (!IsUniform)
UniformityBits[I / 8] &= ~(1 << (I % 8));
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/206547
More information about the llvm-commits
mailing list