[llvm] dd879f7 - [DAG] Use APInt::extractBits instead of lshr().trunc(). NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 16 05:52:58 PST 2021


Author: Simon Pilgrim
Date: 2021-02-16T13:50:33Z
New Revision: dd879f7dc9f5df614431358e11f21c948429eda6

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

LOG: [DAG] Use APInt::extractBits instead of lshr().trunc(). NFCI.

Avoids so many APInt instances by directly using the APInt reference from getAPIntValue.

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index cf1eee48e6b7..eae4c4a7b394 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5568,8 +5568,8 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
     if (N1C) {
       unsigned ElementSize = VT.getSizeInBits();
       unsigned Shift = ElementSize * N2C->getZExtValue();
-      APInt ShiftedVal = N1C->getAPIntValue().lshr(Shift);
-      return getConstant(ShiftedVal.trunc(ElementSize), DL, VT);
+      const APInt &Val = N1C->getAPIntValue();
+      return getConstant(Val.extractBits(ElementSize, Shift), DL, VT);
     }
     break;
   case ISD::EXTRACT_SUBVECTOR:


        


More information about the llvm-commits mailing list