[Support] Use llvm::countr_zero and llvm::Log2_64 in APInt.cpp (NFC)
authorKazu Hirata <kazu@google.com>
Thu, 26 Jan 2023 05:22:11 +0000 (21:22 -0800)
committerKazu Hirata <kazu@google.com>
Thu, 26 Jan 2023 05:22:11 +0000 (21:22 -0800)
commit49f7d2c4f0fa105a854c2aee78347652212ace3d
treec80c8c91b027956f17e2ac2d04f0b901601d347d
parent1a0ec9140c87947599db8d3f864054f62cb13298
[Support] Use llvm::countr_zero and llvm::Log2_64 in APInt.cpp (NFC)

partMSB and partLSB never get 0 as the argument.  That is, we don't
rely on find{First,Last}Set's ability to return
std::numeric_limits<T>::max() on input 0.

This patch replaces partLSB and partMSB with llvm::countr_zero and
llvm::Log2_64, respectively.

FWIW, nobody in LLVM (except unit test MathExtrasTest.cpp) relies on
find{First,Last}Set's ability to return std::numeric_limits<T>::max()
on input 0.
llvm/lib/Support/APInt.cpp