Skip to content

Commit 345b331

Browse files
authored
[AMDGPU][SplitModule] Fix unintentional integer division (#117586)
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.
1 parent 712ef7d commit 345b331

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1101,10 +1101,10 @@ void RecursiveSearchSplitting::pickPartition(unsigned Depth, unsigned Idx,
11011101
if (Entry.CostExcludingGraphEntryPoints > LargeClusterThreshold) {
11021102
// Check if the amount of code in common makes it worth it.
11031103
assert(SimilarDepsCost && Entry.CostExcludingGraphEntryPoints);
1104-
const double Ratio =
1105-
SimilarDepsCost / Entry.CostExcludingGraphEntryPoints;
1104+
const double Ratio = static_cast<double>(SimilarDepsCost) /
1105+
Entry.CostExcludingGraphEntryPoints;
11061106
assert(Ratio >= 0.0 && Ratio <= 1.0);
1107-
if (LargeFnOverlapForMerge > Ratio) {
1107+
if (Ratio > LargeFnOverlapForMerge) {
11081108
// For debug, just print "L", so we'll see "L3=P3" for instance, which
11091109
// will mean we reached max depth and chose P3 based on this
11101110
// heuristic.

0 commit comments

Comments
 (0)