[llvm] 7f1f3af - [APInt] Use APINT_BITS_PER_WORD instead of recomputing it. NFC

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 13 22:16:59 PDT 2024


Author: Craig Topper
Date: 2024-08-13T22:12:37-07:00
New Revision: 7f1f3afd37d7c32f27af3f756080ea916c970902

URL: https://github.com/llvm/llvm-project/commit/7f1f3afd37d7c32f27af3f756080ea916c970902
DIFF: https://github.com/llvm/llvm-project/commit/7f1f3afd37d7c32f27af3f756080ea916c970902.diff

LOG: [APInt] Use APINT_BITS_PER_WORD instead of recomputing it. NFC

Added: 
    

Modified: 
    llvm/lib/Support/APInt.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index 24e136fcb9c7f..87edf74e191d8 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -502,10 +502,10 @@ uint64_t APInt::extractBitsAsZExtValue(unsigned numBits,
   if (loWord == hiWord)
     return (U.pVal[loWord] >> loBit) & maskBits;
 
-  static_assert(8 * sizeof(WordType) <= 64, "This code assumes only two words affected");
-  unsigned wordBits = 8 * sizeof(WordType);
+  static_assert(APINT_BITS_PER_WORD <= 64,
+                "This code assumes only two words affected");
   uint64_t retBits = U.pVal[loWord] >> loBit;
-  retBits |= U.pVal[hiWord] << (wordBits - loBit);
+  retBits |= U.pVal[hiWord] << (APINT_BITS_PER_WORD - loBit);
   retBits &= maskBits;
   return retBits;
 }


        


More information about the llvm-commits mailing list