diff --git a/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp b/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp index 5d7aff1c5092c..3b6c2cbe390ed 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp @@ -149,7 +149,8 @@ static constexpr unsigned InvalidPID = -1; /// \param Dem denominator /// \returns a printable object to print (Num/Dem) using "%0.2f". static auto formatRatioOf(CostType Num, CostType Dem) { - return format("%0.2f", (static_cast(Num) / Dem) * 100); + CostType DemOr1 = Dem ? Dem : 1; + return format("%0.2f", (static_cast(Num) / DemOr1) * 100); } /// Checks whether a given function is non-copyable.