[llvm] 13ed3b4 - [DivisionByConstantInfo] Use APInt::getLowBitsSet instead of getAllOnes+lshr. NFC

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 7 22:32:38 PDT 2024


Author: Craig Topper
Date: 2024-07-07T22:32:14-07:00
New Revision: 13ed3b472b6209ef6f7c5b0ee1eb91e563e01cbc

URL: https://github.com/llvm/llvm-project/commit/13ed3b472b6209ef6f7c5b0ee1eb91e563e01cbc
DIFF: https://github.com/llvm/llvm-project/commit/13ed3b472b6209ef6f7c5b0ee1eb91e563e01cbc.diff

LOG: [DivisionByConstantInfo] Use APInt::getLowBitsSet instead of getAllOnes+lshr. NFC

Added: 
    

Modified: 
    llvm/lib/Support/DivisionByConstantInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/DivisionByConstantInfo.cpp b/llvm/lib/Support/DivisionByConstantInfo.cpp
index 8150bd83c79f4..b0e503003a680 100644
--- a/llvm/lib/Support/DivisionByConstantInfo.cpp
+++ b/llvm/lib/Support/DivisionByConstantInfo.cpp
@@ -79,7 +79,8 @@ UnsignedDivisionByConstantInfo::get(const APInt &D, unsigned LeadingZeros,
   APInt Delta;
   struct UnsignedDivisionByConstantInfo Retval;
   Retval.IsAdd = false; // initialize "add" indicator
-  APInt AllOnes = APInt::getAllOnes(D.getBitWidth()).lshr(LeadingZeros);
+  APInt AllOnes =
+      APInt::getLowBitsSet(D.getBitWidth(), D.getBitWidth() - LeadingZeros);
   APInt SignedMin = APInt::getSignedMinValue(D.getBitWidth());
   APInt SignedMax = APInt::getSignedMaxValue(D.getBitWidth());
 


        


More information about the llvm-commits mailing list