Skip to content

Commit 4c2aba9

Browse files
author
Simon Moll
committed
[VP][ISel] use LEGALPOS for legalization action
Use the VPIntrinsics.def's LEGALPOS that is specified with every VP SDNode to determine which return or operand value type shall be used to infer the legalization action. Reviewed By: frasercrmck Differential Revision: https://reviews.llvm.org/D116594
1 parent 0a07c96 commit 4c2aba9

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

llvm/include/llvm/IR/VPIntrinsics.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
// same name. Since the operands are also the same, we open the property
4040
// scopes for both the VPIntrinsic and the SDNode at once.
4141
// \p VPSD The SelectionDAG Node id (eg VP_ADD).
42-
// \p LEGALPOS The operand position of the SDNode that is used for legalizing
43-
// this SDNode. This can be `-1`, in which case the return type of
44-
// the SDNode is used.
42+
// \p LEGALPOS The operand position of the SDNode that is used for legalizing.
43+
// If LEGALPOS < 0, then the return type given by
44+
// TheNode->getValueType(-1-LEGALPOS) is used.
4545
// \p TDNAME The name of the TableGen definition of this SDNode.
4646
// \p MASKPOS The mask operand position.
4747
// \p EVLPOS The explicit vector length operand position.

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ SDValue VectorLegalizer::LegalizeOp(SDValue Op) {
350350
case ISD::CTPOP:
351351
case ISD::SELECT:
352352
case ISD::VSELECT:
353-
case ISD::VP_SELECT:
354353
case ISD::SELECT_CC:
355354
case ISD::ZERO_EXTEND:
356355
case ISD::ANY_EXTEND:
@@ -459,6 +458,14 @@ SDValue VectorLegalizer::LegalizeOp(SDValue Op) {
459458
Action = TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0));
460459
break;
461460
}
461+
462+
#define BEGIN_REGISTER_VP_SDNODE(VPID, LEGALPOS, ...) \
463+
case ISD::VPID: { \
464+
EVT LegalizeVT = LEGALPOS < 0 ? Node->getValueType(-(1 + LEGALPOS)) \
465+
: Node->getOperand(LEGALPOS).getValueType(); \
466+
Action = TLI.getOperationAction(Node->getOpcode(), LegalizeVT); \
467+
} break;
468+
#include "llvm/IR/VPIntrinsics.def"
462469
}
463470

464471
LLVM_DEBUG(dbgs() << "\nLegalizing vector op: "; Node->dump(&DAG));

0 commit comments

Comments
 (0)