[PATCH] D123112: [VP] Legalize the stride operand for EXPERIMENTAL_VP_STRIDED SDNodes
Lorenzo Albano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 5 03:01:47 PDT 2022
loralb created this revision.
loralb added reviewers: simoll, craig.topper, frasercrmck, rogfer01.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
loralb requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Add promotion and expansion of integer operands for `experimental_vp_strided` SelectionDAG nodes; the expansion is actually just a truncation of the stride operand.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D123112
Files:
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
Index: llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
@@ -402,6 +402,7 @@
SDValue PromoteIntOp_VECREDUCE(SDNode *N);
SDValue PromoteIntOp_VP_REDUCE(SDNode *N, unsigned OpNo);
SDValue PromoteIntOp_SET_ROUNDING(SDNode *N);
+ SDValue PromoteIntOp_VP_STRIDED(SDNode *N, unsigned OpNo);
void PromoteSetCCOperands(SDValue &LHS,SDValue &RHS, ISD::CondCode Code);
@@ -493,6 +494,7 @@
SDValue ExpandIntOp_RETURNADDR(SDNode *N);
SDValue ExpandIntOp_ATOMIC_STORE(SDNode *N);
SDValue ExpandIntOp_SPLAT_VECTOR(SDNode *N);
+ SDValue ExpandIntOp_VP_STRIDED(SDNode *N, unsigned OpNo);
void IntegerExpandSetCCOperands(SDValue &NewLHS, SDValue &NewRHS,
ISD::CondCode &CCCode, const SDLoc &dl);
Index: llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
@@ -1671,6 +1671,10 @@
break;
case ISD::SET_ROUNDING: Res = PromoteIntOp_SET_ROUNDING(N); break;
+ case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
+ case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
+ Res = PromoteIntOp_VP_STRIDED(N, OpNo);
+ break;
}
// If the result is null, the sub-method took care of registering results etc.
@@ -2236,6 +2240,21 @@
return SDValue(DAG.UpdateNodeOperands(N, N->getOperand(0), Op), 0);
}
+SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(SDNode *N, unsigned OpNo) {
+ if (N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD)
+ assert(OpNo == 3 && "Unexpected operand for promotion");
+ else {
+ assert(N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE &&
+ "Invalid opcode");
+ assert(OpNo == 4 && "Unexpected operand for promotion");
+ }
+
+ SmallVector<SDValue, 8> NewOps(N->op_begin(), N->op_end());
+ NewOps[OpNo] = SExtPromotedInteger(N->getOperand(OpNo));
+
+ return SDValue(DAG.UpdateNodeOperands(N, NewOps), 0);
+}
+
//===----------------------------------------------------------------------===//
// Integer Result Expansion
//===----------------------------------------------------------------------===//
@@ -4588,6 +4607,11 @@
case ISD::FRAMEADDR: Res = ExpandIntOp_RETURNADDR(N); break;
case ISD::ATOMIC_STORE: Res = ExpandIntOp_ATOMIC_STORE(N); break;
+
+ case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
+ case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
+ Res = ExpandIntOp_VP_STRIDED(N, OpNo);
+ break;
}
// If the result is null, the sub-method took care of registering results etc.
@@ -5003,6 +5027,27 @@
return Swap.getValue(1);
}
+SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(SDNode *N, unsigned OpNo) {
+ if (N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD)
+ assert(OpNo == 3 && "Unexpected operand for expansion");
+ else {
+ assert(N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE &&
+ "Invalid opcode");
+ assert(OpNo == 4 && "Unexpected operand for expansion");
+ }
+
+ SDLoc DL(N);
+ EVT SrcVT = N->getOperand(OpNo).getValueType();
+ EVT DestVT = TLI.getTypeToTransformTo(*DAG.getContext(), SrcVT);
+ assert(DestVT.getSizeInBits() < SrcVT.getSizeInBits() &&
+ "Stride operand should be truncated!");
+
+ SmallVector<SDValue, 8> NewOps(N->op_begin(), N->op_end());
+ NewOps[OpNo] = DAG.getAnyExtOrTrunc(N->getOperand(OpNo), DL, DestVT);
+
+ return SDValue(DAG.UpdateNodeOperands(N, NewOps), 0);
+}
+
SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(SDNode *N) {
SDLoc dl(N);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123112.420427.patch
Type: text/x-patch
Size: 3729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220405/5077c939/attachment.bin>
More information about the llvm-commits
mailing list