[llvm] 5ed8cea - [Support] APInt.h - remove <algorithm> include. NFCI.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 21 16:43:34 PDT 2021


Any particular data that suggests removing this #include is worthwhile?

On Tue, Apr 20, 2021 at 3:23 AM Simon Pilgrim via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

>
> Author: Simon Pilgrim
> Date: 2021-04-20T11:21:39+01:00
> New Revision: 5ed8cea9a8166b81ade4a9352971ba061f9b6f65
>
> URL:
> https://github.com/llvm/llvm-project/commit/5ed8cea9a8166b81ade4a9352971ba061f9b6f65
> DIFF:
> https://github.com/llvm/llvm-project/commit/5ed8cea9a8166b81ade4a9352971ba061f9b6f65.diff
>
> LOG: [Support] APInt.h - remove <algorithm> include. NFCI.
>
> Replace std::min use which should allow us to avoid including the
> <algorithm> header in every include of APInt.h.
>
> Added:
>
>
> Modified:
>     llvm/include/llvm/ADT/APInt.h
>
> Removed:
>
>
>
>
> ################################################################################
> diff  --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
> index 0fca6bac43fd9..0cd4a0c9fc9f7 100644
> --- a/llvm/include/llvm/ADT/APInt.h
> +++ b/llvm/include/llvm/ADT/APInt.h
> @@ -17,7 +17,6 @@
>
>  #include "llvm/Support/Compiler.h"
>  #include "llvm/Support/MathExtras.h"
> -#include <algorithm>
>  #include <cassert>
>  #include <climits>
>  #include <cstring>
> @@ -1699,8 +1698,10 @@ class LLVM_NODISCARD APInt {
>    /// \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();
>    }
>
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210421/25e56c85/attachment.html>


More information about the llvm-commits mailing list