[llvm] [AMDGPU][SplitModule] Fix unintentional integer division (PR #117586)
Fraser Cormack via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 26 02:30:13 PST 2024
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/117586
>From 70ce91dd4632aea58bca0ea25cc83e1a4166fa01 Mon Sep 17 00:00:00 2001
From: Fraser Cormack <fraser at codeplay.com>
Date: Mon, 25 Nov 2024 17:56:50 +0000
Subject: [PATCH] [AMDGPU][SplitModule] Fix unintentional integer division
A static analysis tool warned that a division was always being performed
in integer division, so was either 0.0 or 1.0.
This doesn't seem intentional, so has been fixed to return a true ratio
using floating-point division. This in turn showed a bug where a
comparison against this ratio was incorrect.
---
llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp b/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp
index 5d7aff1c5092cc..6adb43a153999a 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp
@@ -1101,9 +1101,9 @@ void RecursiveSearchSplitting::pickPartition(unsigned Depth, unsigned Idx,
// Check if the amount of code in common makes it worth it.
assert(SimilarDepsCost && Entry.CostExcludingGraphEntryPoints);
const double Ratio =
- SimilarDepsCost / Entry.CostExcludingGraphEntryPoints;
+ (double)SimilarDepsCost / Entry.CostExcludingGraphEntryPoints;
assert(Ratio >= 0.0 && Ratio <= 1.0);
- if (LargeFnOverlapForMerge > Ratio) {
+ if (Ratio > LargeFnOverlapForMerge) {
// For debug, just print "L", so we'll see "L3=P3" for instance, which
// will mean we reached max depth and chose P3 based on this
// heuristic.
More information about the llvm-commits
mailing list