[PATCH] D131642: [LegalizeTypes][NFC] Use getConstantOperandVal instead of cast constant getvalue.

WangLian via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 10 20:11:18 PDT 2022


Jimerlife created this revision.
Jimerlife added reviewers: craig.topper, sdesmalen, frasercrmck, benshi001.
Jimerlife added a project: LLVM.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
Jimerlife requested review of this revision.
Herald added subscribers: llvm-commits, jacquesguan.

Use getConstantOperandVal  API instead of `cast<ConstantSDNode>(Op)->getZExtValue()`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131642

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
@@ -1362,7 +1362,7 @@
   std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(N->getValueType(0));
 
   Lo = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, LoVT, Vec, Idx);
-  uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
+  uint64_t IdxVal = N->getConstantOperandVal(1);
   Hi = DAG.getNode(
       ISD::EXTRACT_SUBVECTOR, dl, HiVT, Vec,
       DAG.getVectorIdxConstant(IdxVal + LoVT.getVectorMinNumElements(), dl));
@@ -1386,7 +1386,7 @@
   // If we know the index is in the first half, and we know the subvector
   // doesn't cross the boundary between the halves, we can avoid spilling the
   // vector, and insert into the lower half of the split vector directly.
-  unsigned IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
+  uint64_t IdxVal = N->getConstantOperandVal(2);
   if (IdxVal + SubElems <= LoElems) {
     Lo = DAG.getNode(ISD::INSERT_SUBVECTOR, dl, LoVT, Lo, SubVec, Idx);
     return;
@@ -2988,7 +2988,7 @@
   SDValue Lo, Hi;
   GetSplitVector(SubVec, Lo, Hi);
 
-  uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
+  uint64_t IdxVal = N->getConstantOperandVal(2);
   uint64_t LoElts = Lo.getValueType().getVectorMinNumElements();
 
   SDValue FirstInsertion =
@@ -3016,7 +3016,7 @@
   GetSplitVector(N->getOperand(0), Lo, Hi);
 
   uint64_t LoElts = Lo.getValueType().getVectorMinNumElements();
-  uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
+  uint64_t IdxVal = N->getConstantOperandVal(1);
 
   if (IdxVal < LoElts) {
     assert(IdxVal + SubVT.getVectorMinNumElements() <= LoElts &&
@@ -4771,7 +4771,7 @@
   EVT InVT = InOp.getValueType();
 
   // Check if we can just return the input vector after widening.
-  uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
+  uint64_t IdxVal = N->getConstantOperandVal(1);
   if (IdxVal == 0 && InVT == WidenVT)
     return InOp;
 
Index: llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
@@ -5188,7 +5188,7 @@
         getTypeAction(InVT) == TargetLowering::TypeLegal) {
       EVT NInVT = InVT.getHalfNumVectorElementsVT(*DAG.getContext());
       unsigned NElts = NInVT.getVectorMinNumElements();
-      uint64_t IdxVal = cast<ConstantSDNode>(BaseIdx)->getZExtValue();
+      uint64_t IdxVal = N->getConstantOperandVal(1);
 
       SDValue Step1 = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, NInVT, InOp0,
                                   DAG.getConstant(alignDown(IdxVal, NElts), dl,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131642.451710.patch
Type: text/x-patch
Size: 2826 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220811/0c9ea5a2/attachment.bin>


More information about the llvm-commits mailing list