Skip to content

Commit 70ce91d

Browse files
committed
[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.
1 parent 99fd1c5 commit 70ce91d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp

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

0 commit comments

Comments
 (0)