[llvm] 3b71f1d - [LegalizeTypes][NFC] Use getConstantOperandAPInt instead of cast constant getAPInt

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 11 19:22:06 PDT 2022


Author: wanglian
Date: 2022-08-12T10:21:54+08:00
New Revision: 3b71f1d5abaa9a3ee361e581ceb023adc3b0726b

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

LOG: [LegalizeTypes][NFC] Use getConstantOperandAPInt instead of cast constant getAPInt

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D131653

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
index dc087679fa631..9611c8f77f93b 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
@@ -1555,7 +1555,7 @@ SDValue DAGTypeLegalizer::PromoteIntRes_UNDEF(SDNode *N) {
 SDValue DAGTypeLegalizer::PromoteIntRes_VSCALE(SDNode *N) {
   EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
 
-  APInt MulImm = cast<ConstantSDNode>(N->getOperand(0))->getAPIntValue();
+  const APInt &MulImm = N->getConstantOperandAPInt(0);
   return DAG.getVScale(SDLoc(N), VT, MulImm.sext(VT.getSizeInBits()));
 }
 
@@ -5352,7 +5352,7 @@ SDValue DAGTypeLegalizer::PromoteIntRes_STEP_VECTOR(SDNode *N) {
   EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
   assert(NOutVT.isScalableVector() &&
          "Type must be promoted to a scalable vector type");
-  APInt StepVal = cast<ConstantSDNode>(N->getOperand(0))->getAPIntValue();
+  const APInt &StepVal = N->getConstantOperandAPInt(0);
   return DAG.getStepVector(dl, NOutVT,
                            StepVal.sext(NOutVT.getScalarSizeInBits()));
 }


        


More information about the llvm-commits mailing list