-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[LLVM][CodeGen][SVE] Add lowering for ISD::[ANY,SIGN,ZERO]_EXTEND_VECTOR_INREG. #169847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1591,6 +1591,10 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM, | |
| setOperationAction(ISD::AVGCEILS, VT, Custom); | ||
| setOperationAction(ISD::AVGCEILU, VT, Custom); | ||
|
|
||
| setOperationAction(ISD::ANY_EXTEND_VECTOR_INREG, VT, Custom); | ||
| setOperationAction(ISD::SIGN_EXTEND_VECTOR_INREG, VT, Custom); | ||
| setOperationAction(ISD::ZERO_EXTEND_VECTOR_INREG, VT, Custom); | ||
|
|
||
| if (!Subtarget->isLittleEndian()) | ||
| setOperationAction(ISD::BITCAST, VT, Custom); | ||
|
|
||
|
|
@@ -7851,6 +7855,9 @@ SDValue AArch64TargetLowering::LowerOperation(SDValue Op, | |
| return LowerEXTRACT_VECTOR_ELT(Op, DAG); | ||
| case ISD::BUILD_VECTOR: | ||
| return LowerBUILD_VECTOR(Op, DAG); | ||
| case ISD::ANY_EXTEND_VECTOR_INREG: | ||
| case ISD::SIGN_EXTEND_VECTOR_INREG: | ||
| return LowerEXTEND_VECTOR_INREG(Op, DAG); | ||
| case ISD::ZERO_EXTEND_VECTOR_INREG: | ||
| return LowerZERO_EXTEND_VECTOR_INREG(Op, DAG); | ||
| case ISD::VECTOR_SHUFFLE: | ||
|
|
@@ -14688,6 +14695,40 @@ static SDValue tryToConvertShuffleOfTbl2ToTbl4(SDValue Op, | |
| Tbl2->getOperand(1), Tbl2->getOperand(2), TBLMask}); | ||
| } | ||
|
|
||
| SDValue | ||
| AArch64TargetLowering::LowerEXTEND_VECTOR_INREG(SDValue Op, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: It's a minor thing, but we already have a LowerZERO_EXTEND_VECTOR_INREG, so at first it confused me a little why this was named as if it handles all extends. Then I realised it does handle all extends for scalable vectors only. I realise it's a bit verbose, but is it worth making it clear this is for scalable vectors only? For example, something like
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure because I'm likely to extend this function for SVE VLS as well? Also, looking at the current implementation of LowerZERO_EXTEND_VECTOR_INREG I think this is another of those cases where we can do better for NEON vectors when SVE is available. What do you think?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough, that makes sense. |
||
| SelectionDAG &DAG) const { | ||
| SDLoc DL(Op); | ||
| EVT VT = Op.getValueType(); | ||
| assert(VT.isScalableVector() && "Unexpected result type!"); | ||
|
|
||
| bool Signed = Op.getOpcode() == ISD::SIGN_EXTEND_VECTOR_INREG; | ||
| unsigned UnpackOpcode = Signed ? AArch64ISD::SUNPKLO : AArch64ISD::UUNPKLO; | ||
|
|
||
| // Repeatedly unpack Val until the result is of the desired type. | ||
| SDValue Val = Op.getOperand(0); | ||
| switch (Val.getSimpleValueType().SimpleTy) { | ||
| default: | ||
| return SDValue(); | ||
| case MVT::nxv16i8: | ||
| Val = DAG.getNode(UnpackOpcode, DL, MVT::nxv8i16, Val); | ||
| if (VT == MVT::nxv8i16) | ||
| break; | ||
| [[fallthrough]]; | ||
| case MVT::nxv8i16: | ||
| Val = DAG.getNode(UnpackOpcode, DL, MVT::nxv4i32, Val); | ||
| if (VT == MVT::nxv4i32) | ||
| break; | ||
| [[fallthrough]]; | ||
| case MVT::nxv4i32: | ||
| Val = DAG.getNode(UnpackOpcode, DL, MVT::nxv2i64, Val); | ||
| assert(VT == MVT::nxv2i64 && "Unexpected result type!"); | ||
| break; | ||
| } | ||
|
|
||
| return Val; | ||
| } | ||
|
|
||
| // Baseline legalization for ZERO_EXTEND_VECTOR_INREG will blend-in zeros, | ||
| // but we don't have an appropriate instruction, | ||
| // so custom-lower it as ZIP1-with-zeros. | ||
|
|
@@ -14696,6 +14737,10 @@ AArch64TargetLowering::LowerZERO_EXTEND_VECTOR_INREG(SDValue Op, | |
| SelectionDAG &DAG) const { | ||
| SDLoc DL(Op); | ||
| EVT VT = Op.getValueType(); | ||
|
|
||
| if (VT.isScalableVector()) | ||
| return LowerEXTEND_VECTOR_INREG(Op, DAG); | ||
|
|
||
| SDValue SrcOp = Op.getOperand(0); | ||
| EVT SrcVT = SrcOp.getValueType(); | ||
| assert(VT.getScalarSizeInBits() % SrcVT.getScalarSizeInBits() == 0 && | ||
|
|
@@ -28872,7 +28917,8 @@ void AArch64TargetLowering::ReplaceExtractSubVectorResults( | |
| if ((Index != 0) && (Index != ResEC.getKnownMinValue())) | ||
| return; | ||
|
|
||
| unsigned Opcode = (Index == 0) ? AArch64ISD::UUNPKLO : AArch64ISD::UUNPKHI; | ||
| unsigned Opcode = (Index == 0) ? (unsigned)ISD::ANY_EXTEND_VECTOR_INREG | ||
| : (unsigned)AArch64ISD::UUNPKHI; | ||
| EVT ExtendedHalfVT = VT.widenIntegerVectorElementType(*DAG.getContext()); | ||
|
|
||
| SDValue Half = DAG.getNode(Opcode, DL, ExtendedHalfVT, N->getOperand(0)); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know if the VT refers to src or dest VT here? If it's the src, does that mean we also need to test extends from something like nxv2i64 -> nxv2i128?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For
###_EXTEND_VECTOR_INREGthe result type is used. The operations require both types to be the same size so it would benxv2i64 -> nxv1i128, which is not a legal type so the current lowering code wouldn't apply.I'm pretty sure that means this case will fail, but that's no worse than today.