diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp --- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp +++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp @@ -26,6 +26,7 @@ #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/IntrinsicsAMDGPU.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/MathExtras.h" #include "llvm/Target/TargetMachine.h" using namespace llvm; @@ -4244,7 +4245,7 @@ unsigned AddrComponents = (BaseOpcode->Coordinates ? Dim->NumCoords : 0) + (BaseOpcode->LodOrClampOrMip ? 1 : 0); if (IsA16) - AddrWords += (AddrComponents + 1) / 2; + AddrWords += divideCeil(AddrComponents, 2); else AddrWords += AddrComponents; @@ -4252,7 +4253,7 @@ if (PackDerivatives) // There are two gradients per coordinate, we pack them separately. // For the 3d case, we get (dy/du, dx/du) (-, dz/du) (dy/dv, dx/dv) (-, dz/dv) - AddrWords += (Dim->NumGradients / 2 + 1) / 2 * 2; + AddrWords += alignTo<2>(Dim->NumGradients / 2); else AddrWords += Dim->NumGradients; }