[clang] 63c4967 - Use APInt::getOneBitSet (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 10 18:19:28 PDT 2023


Author: Kazu Hirata
Date: 2023-04-10T18:19:17-07:00
New Revision: 63c4967352247705b4513ab17b7a4ee66cd6d1ea

URL: https://github.com/llvm/llvm-project/commit/63c4967352247705b4513ab17b7a4ee66cd6d1ea
DIFF: https://github.com/llvm/llvm-project/commit/63c4967352247705b4513ab17b7a4ee66cd6d1ea.diff

LOG: Use APInt::getOneBitSet (NFC)

Added: 
    

Modified: 
    clang/lib/CodeGen/CGExprCXX.cpp
    llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index 2b0c31bfef8c1..c37fa3f75c234 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -829,8 +829,8 @@ static llvm::Value *EmitCXXNewAllocSize(CodeGenFunction &CGF,
     // going to have to do a comparison for (2), and this happens to
     // take care of (1), too.
     if (numElementsWidth > sizeWidth) {
-      llvm::APInt threshold(numElementsWidth, 1);
-      threshold <<= sizeWidth;
+      llvm::APInt threshold =
+          llvm::APInt::getOneBitSet(numElementsWidth, sizeWidth);
 
       llvm::Value *thresholdV
         = llvm::ConstantInt::get(numElementsType, threshold);

diff  --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 55f716a45ca91..156b1c9ba6199 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -8811,8 +8811,7 @@ SDValue TargetLowering::expandBITREVERSE(SDNode *N, SelectionDAG &DAG) const {
       Tmp2 =
           DAG.getNode(ISD::SRL, dl, VT, Op, DAG.getConstant(I - J, dl, SHVT));
 
-    APInt Shift(Sz, 1);
-    Shift <<= J;
+    APInt Shift = APInt::getOneBitSet(Sz, J);
     Tmp2 = DAG.getNode(ISD::AND, dl, VT, Tmp2, DAG.getConstant(Shift, dl, VT));
     Tmp = DAG.getNode(ISD::OR, dl, VT, Tmp, Tmp2);
   }


        


More information about the cfe-commits mailing list