Index: include/llvm/Support/MathExtras.h =================================================================== --- include/llvm/Support/MathExtras.h +++ include/llvm/Support/MathExtras.h @@ -670,6 +670,10 @@ /// \endcode inline uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew = 0) { assert(Align != 0u && "Align can't be 0."); + if (LLVM_LIKELY(isPowerOf2_64(Align))) { + Skew &= Align - 1; + return ((Value + Align - 1 - Skew) & -Align) + Skew; + } Skew %= Align; return (Value + Align - 1 - Skew) / Align * Align + Skew; }