diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp --- a/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp @@ -117,8 +117,7 @@ if (!MF.getSubtarget().hasAtomics()) break; - uint64_t SyncScopeID = - cast(Node->getOperand(2).getNode())->getZExtValue(); + uint64_t SyncScopeID = Node->getConstantOperandVal(2); MachineSDNode *Fence = nullptr; switch (SyncScopeID) { case SyncScope::SingleThread: @@ -152,7 +151,7 @@ } case ISD::INTRINSIC_WO_CHAIN: { - unsigned IntNo = cast(Node->getOperand(0))->getZExtValue(); + unsigned IntNo = Node->getConstantOperandVal(0); switch (IntNo) { case Intrinsic::wasm_tls_size: { MachineSDNode *TLSSize = CurDAG->getMachineNode( @@ -174,7 +173,7 @@ } case ISD::INTRINSIC_W_CHAIN: { - unsigned IntNo = cast(Node->getOperand(1))->getZExtValue(); + unsigned IntNo = Node->getConstantOperandVal(1); const auto &TLI = CurDAG->getTargetLoweringInfo(); MVT PtrVT = TLI.getPointerTy(CurDAG->getDataLayout()); switch (IntNo) { diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp --- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp @@ -830,7 +830,7 @@ default: break; case ISD::INTRINSIC_WO_CHAIN: { - unsigned IntNo = cast(Op.getOperand(0))->getZExtValue(); + unsigned IntNo = Op.getConstantOperandVal(0); switch (IntNo) { default: break; @@ -1492,7 +1492,7 @@ if (verifyReturnAddressArgumentIsConstant(Op, DAG)) return SDValue(); - unsigned Depth = cast(Op.getOperand(0))->getZExtValue(); + unsigned Depth = Op.getConstantOperandVal(0); MakeLibCallOptions CallOptions; return makeLibCall(DAG, RTLIB::RETURN_ADDRESS, Op.getValueType(), {DAG.getConstant(Depth, DL, MVT::i32)}, CallOptions, DL) @@ -1671,10 +1671,10 @@ switch (Op.getOpcode()) { case ISD::INTRINSIC_VOID: case ISD::INTRINSIC_W_CHAIN: - IntNo = cast(Op.getOperand(1))->getZExtValue(); + IntNo = Op.getConstantOperandVal(1); break; case ISD::INTRINSIC_WO_CHAIN: - IntNo = cast(Op.getOperand(0))->getZExtValue(); + IntNo = Op.getConstantOperandVal(0); break; default: llvm_unreachable("Invalid intrinsic");