diff --git a/llvm/include/llvm/CodeGen/ISDOpcodes.h b/llvm/include/llvm/CodeGen/ISDOpcodes.h --- a/llvm/include/llvm/CodeGen/ISDOpcodes.h +++ b/llvm/include/llvm/CodeGen/ISDOpcodes.h @@ -1363,7 +1363,7 @@ std::optional getBaseOpcodeForVP(unsigned Opcode, bool hasFPExcept); /// Translate this non-VP Opcode to its corresponding VP Opcode. -unsigned getVPForBaseOpcode(unsigned Opcode); +std::optional getVPForBaseOpcode(unsigned Opcode); //===--------------------------------------------------------------------===// /// MemIndexedMode enum - This enum defines the load / store indexed diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -934,7 +934,7 @@ // SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT) { return // DAG.getNode(Opcode, DL, VT); } SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue Operand) { - unsigned VPOpcode = ISD::getVPForBaseOpcode(Opcode); + unsigned VPOpcode = ISD::getVPForBaseOpcode(Opcode).value(); assert(ISD::getVPMaskIdx(VPOpcode) == 1 && ISD::getVPExplicitVectorLengthIdx(VPOpcode) == 2); return DAG.getNode(VPOpcode, DL, VT, @@ -943,7 +943,7 @@ SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1, SDValue N2) { - unsigned VPOpcode = ISD::getVPForBaseOpcode(Opcode); + unsigned VPOpcode = ISD::getVPForBaseOpcode(Opcode).value(); assert(ISD::getVPMaskIdx(VPOpcode) == 2 && ISD::getVPExplicitVectorLengthIdx(VPOpcode) == 3); return DAG.getNode(VPOpcode, DL, VT, @@ -952,7 +952,7 @@ SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1, SDValue N2, SDValue N3) { - unsigned VPOpcode = ISD::getVPForBaseOpcode(Opcode); + unsigned VPOpcode = ISD::getVPForBaseOpcode(Opcode).value(); assert(ISD::getVPMaskIdx(VPOpcode) == 3 && ISD::getVPExplicitVectorLengthIdx(VPOpcode) == 4); return DAG.getNode(VPOpcode, DL, VT, @@ -961,7 +961,7 @@ SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue Operand, SDNodeFlags Flags) { - unsigned VPOpcode = ISD::getVPForBaseOpcode(Opcode); + unsigned VPOpcode = ISD::getVPForBaseOpcode(Opcode).value(); assert(ISD::getVPMaskIdx(VPOpcode) == 1 && ISD::getVPExplicitVectorLengthIdx(VPOpcode) == 2); return DAG.getNode(VPOpcode, DL, VT, {Operand, RootMaskOp, RootVectorLenOp}, @@ -970,7 +970,7 @@ SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1, SDValue N2, SDNodeFlags Flags) { - unsigned VPOpcode = ISD::getVPForBaseOpcode(Opcode); + unsigned VPOpcode = ISD::getVPForBaseOpcode(Opcode).value(); assert(ISD::getVPMaskIdx(VPOpcode) == 2 && ISD::getVPExplicitVectorLengthIdx(VPOpcode) == 3); return DAG.getNode(VPOpcode, DL, VT, {N1, N2, RootMaskOp, RootVectorLenOp}, @@ -979,7 +979,7 @@ SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1, SDValue N2, SDValue N3, SDNodeFlags Flags) { - unsigned VPOpcode = ISD::getVPForBaseOpcode(Opcode); + unsigned VPOpcode = ISD::getVPForBaseOpcode(Opcode).value(); assert(ISD::getVPMaskIdx(VPOpcode) == 3 && ISD::getVPExplicitVectorLengthIdx(VPOpcode) == 4); return DAG.getNode(VPOpcode, DL, VT, @@ -988,7 +988,7 @@ bool isOperationLegalOrCustom(unsigned Op, EVT VT, bool LegalOnly = false) const { - unsigned VPOp = ISD::getVPForBaseOpcode(Op); + unsigned VPOp = ISD::getVPForBaseOpcode(Op).value(); return TLI.isOperationLegalOrCustom(VPOp, VT, LegalOnly); } }; diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -531,10 +531,10 @@ return std::nullopt; } -unsigned ISD::getVPForBaseOpcode(unsigned Opcode) { +std::optional ISD::getVPForBaseOpcode(unsigned Opcode) { switch (Opcode) { default: - llvm_unreachable("can not translate this Opcode to VP."); + return std::nullopt; #define BEGIN_REGISTER_VP_SDNODE(VPOPC, ...) break; #define VP_PROPERTY_FUNCTIONAL_SDOPC(SDOPC) case ISD::SDOPC: #define END_REGISTER_VP_SDNODE(VPOPC) return ISD::VPOPC;