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

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 20 03:23:50 PDT 2021


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();
   }
 


        


More information about the llvm-commits mailing list