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 @@ -4244,7 +4244,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 +4252,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; }