[llvm] [MLGO] Use double comparison facilities for reg alloc scoring tests (PR #88862)
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 16 02:30:07 PDT 2024
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/88862
This patch switches from using direct equality (ASSERT_EQ) to the floating point comparison facilities (ASSERT_DOUBLE_EQ) within google test to avoid weird floating point problems. There is at least one downstream that maintains a patch for issues cropping up from the direct equality.
https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/main/llvm17/allocscore.patch
>From 579719563628e14cf14558d03decc030c44ba12e Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Tue, 16 Apr 2024 09:27:48 +0000
Subject: [PATCH] [MLGO] Use double comparison facilities for reg alloc scoring
tests
This patch switches from using direct equality (ASSERT_EQ) to the
floating point comparison facilities (ASSERT_DOUBLE_EQ) within google
test to avoid weird floating point problems. There is at least one
downstream that maintains a patch for issues cropping up from the direct
equality.
https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/main/llvm17/allocscore.patch
---
llvm/unittests/CodeGen/RegAllocScoreTest.cpp | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/llvm/unittests/CodeGen/RegAllocScoreTest.cpp b/llvm/unittests/CodeGen/RegAllocScoreTest.cpp
index ff7146eaf9439a..eeeec751a023f8 100644
--- a/llvm/unittests/CodeGen/RegAllocScoreTest.cpp
+++ b/llvm/unittests/CodeGen/RegAllocScoreTest.cpp
@@ -166,13 +166,13 @@ TEST(RegAllocScoreTest, Counts) {
ASSERT_EQ(MF->size(), 2U);
const auto TotalScore =
llvm::calculateRegAllocScore(*MF, MBBFreqMock, IsRemat);
- ASSERT_EQ(Freq1, TotalScore.copyCounts());
- ASSERT_EQ(2.0 * Freq1 + Freq2, TotalScore.loadCounts());
- ASSERT_EQ(Freq1 + Freq2, TotalScore.storeCounts());
- ASSERT_EQ(Freq2, TotalScore.loadStoreCounts());
- ASSERT_EQ(Freq1, TotalScore.cheapRematCounts());
- ASSERT_EQ(Freq2, TotalScore.expensiveRematCounts());
- ASSERT_EQ(TotalScore.getScore(),
+ ASSERT_DOUBLE_EQ(Freq1, TotalScore.copyCounts());
+ ASSERT_DOUBLE_EQ(2.0 * Freq1 + Freq2, TotalScore.loadCounts());
+ ASSERT_DOUBLE_EQ(Freq1 + Freq2, TotalScore.storeCounts());
+ ASSERT_DOUBLE_EQ(Freq2, TotalScore.loadStoreCounts());
+ ASSERT_DOUBLE_EQ(Freq1, TotalScore.cheapRematCounts());
+ ASSERT_DOUBLE_EQ(Freq2, TotalScore.expensiveRematCounts());
+ ASSERT_DOUBLE_EQ(TotalScore.getScore(),
TotalScore.copyCounts() * CopyWeight +
TotalScore.loadCounts() * LoadWeight +
TotalScore.storeCounts() * StoreWeight +
More information about the llvm-commits
mailing list