diff --git a/llvm/include/llvm/IR/VPIntrinsics.def b/llvm/include/llvm/IR/VPIntrinsics.def --- a/llvm/include/llvm/IR/VPIntrinsics.def +++ b/llvm/include/llvm/IR/VPIntrinsics.def @@ -39,9 +39,9 @@ // same name. Since the operands are also the same, we open the property // scopes for both the VPIntrinsic and the SDNode at once. // \p VPSD The SelectionDAG Node id (eg VP_ADD). -// \p LEGALPOS The operand position of the SDNode that is used for legalizing -// this SDNode. This can be `-1`, in which case the return type of -// the SDNode is used. +// \p LEGALPOS The operand position of the SDNode that is used for legalizing. +// If LEGALPOS < 0, then the return type given by +// TheNode->getValueType(-1-LEGALPOS) is used. // \p TDNAME The name of the TableGen definition of this SDNode. // \p MASKPOS The mask operand position. // \p EVLPOS The explicit vector length operand position. diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp @@ -350,7 +350,6 @@ case ISD::CTPOP: case ISD::SELECT: case ISD::VSELECT: - case ISD::VP_SELECT: case ISD::SELECT_CC: case ISD::ZERO_EXTEND: case ISD::ANY_EXTEND: @@ -459,6 +458,14 @@ Action = TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0)); break; } + +#define BEGIN_REGISTER_VP_SDNODE(VPID, LEGALPOS, ...) \ + case ISD::VPID: { \ + EVT LegalizeVT = LEGALPOS < 0 ? Node->getValueType(-(1 + LEGALPOS)) \ + : Node->getOperand(LEGALPOS).getValueType(); \ + Action = TLI.getOperationAction(Node->getOpcode(), LegalizeVT); \ + } break; +#include "llvm/IR/VPIntrinsics.def" } LLVM_DEBUG(dbgs() << "\nLegalizing vector op: "; Node->dump(&DAG));