diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index 0fca6bac43f..0cd4a0c9fc9 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -17,7 +17,6 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/MathExtras.h" -#include #include #include #include @@ -1699,8 +1698,10 @@ public: /// \returns BitWidth if the value is zero, otherwise returns the number of /// zeros from the least significant bit to the first one bit. unsigned countTrailingZeros() const { - if (isSingleWord()) - return std::min(unsigned(llvm::countTrailingZeros(U.VAL)), BitWidth); + if (isSingleWord()) { + unsigned TrailingZeros = llvm::countTrailingZeros(U.VAL); + return (TrailingZeros > BitWidth ? BitWidth : TrailingZeros); + } return countTrailingZerosSlowCase(); }