-
Notifications
You must be signed in to change notification settings - Fork 15.9k
[RISCV] Lower unmasked zero-stride vp.stride to a splat of one scalar load. #97394
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 1 commit
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 |
|---|---|---|
|
|
@@ -11666,31 +11666,54 @@ SDValue RISCVTargetLowering::lowerVPStridedLoad(SDValue Op, | |
| auto *VPNode = cast<VPStridedLoadSDNode>(Op); | ||
| // Check if the mask is known to be all ones | ||
| SDValue Mask = VPNode->getMask(); | ||
| SDValue VL = VPNode->getVectorLength(); | ||
| SDValue Stride = VPNode->getStride(); | ||
| bool IsUnmasked = ISD::isConstantSplatVectorAllOnes(Mask.getNode()); | ||
|
|
||
| SDValue IntID = DAG.getTargetConstant(IsUnmasked ? Intrinsic::riscv_vlse | ||
| : Intrinsic::riscv_vlse_mask, | ||
| DL, XLenVT); | ||
| SmallVector<SDValue, 8> Ops{VPNode->getChain(), IntID, | ||
| DAG.getUNDEF(ContainerVT), VPNode->getBasePtr(), | ||
| VPNode->getStride()}; | ||
| if (!IsUnmasked) { | ||
| if (VT.isFixedLengthVector()) { | ||
| MVT MaskVT = ContainerVT.changeVectorElementType(MVT::i1); | ||
| Mask = convertToScalableVector(MaskVT, Mask, DAG, Subtarget); | ||
| SDValue Result, Chain; | ||
|
|
||
| // TODO: We restrict this to unmasked loads currently in consideration of | ||
| // the complexity of handling all falses masks. | ||
| MVT ScalarVT = ContainerVT.getVectorElementType(); | ||
| if (IsUnmasked && isNullConstant(Stride) && ContainerVT.isInteger()) { | ||
| SDValue ScalarLoad = | ||
| DAG.getExtLoad(ISD::EXTLOAD, DL, XLenVT, VPNode->getChain(), | ||
| VPNode->getBasePtr(), ScalarVT, VPNode->getMemOperand()); | ||
| Chain = ScalarLoad.getValue(1); | ||
|
Comment on lines
+11679
to
+11682
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. I just noticed this is the same code as how I see the requirement for it being unmasked was discussed here but I can't see the AVL mentioned. Maybe I'm missing something.
Contributor
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. I think you are right, we should also check avl. BTW, |
||
| Result = lowerScalarSplat(SDValue(), ScalarLoad, VL, ContainerVT, DL, DAG, | ||
| Subtarget); | ||
| } else if (IsUnmasked && isNullConstant(Stride) && isTypeLegal(ScalarVT)) { | ||
| SDValue ScalarLoad = | ||
| DAG.getLoad(ScalarVT, DL, VPNode->getChain(), VPNode->getBasePtr(), | ||
| VPNode->getMemOperand()); | ||
| Chain = ScalarLoad.getValue(1); | ||
| Result = lowerScalarSplat(SDValue(), ScalarLoad, VL, ContainerVT, DL, DAG, | ||
| Subtarget); | ||
| } else { | ||
| SDValue IntID = DAG.getTargetConstant( | ||
| IsUnmasked ? Intrinsic::riscv_vlse : Intrinsic::riscv_vlse_mask, DL, | ||
| XLenVT); | ||
| SmallVector<SDValue, 8> Ops{VPNode->getChain(), IntID, | ||
| DAG.getUNDEF(ContainerVT), VPNode->getBasePtr(), | ||
| Stride}; | ||
| if (!IsUnmasked) { | ||
| if (VT.isFixedLengthVector()) { | ||
| MVT MaskVT = ContainerVT.changeVectorElementType(MVT::i1); | ||
| Mask = convertToScalableVector(MaskVT, Mask, DAG, Subtarget); | ||
| } | ||
| Ops.push_back(Mask); | ||
| } | ||
| Ops.push_back(VL); | ||
| if (!IsUnmasked) { | ||
| SDValue Policy = | ||
| DAG.getTargetConstant(RISCVII::TAIL_AGNOSTIC, DL, XLenVT); | ||
| Ops.push_back(Policy); | ||
| } | ||
| Ops.push_back(Mask); | ||
| } | ||
| Ops.push_back(VPNode->getVectorLength()); | ||
| if (!IsUnmasked) { | ||
| SDValue Policy = DAG.getTargetConstant(RISCVII::TAIL_AGNOSTIC, DL, XLenVT); | ||
| Ops.push_back(Policy); | ||
| } | ||
|
|
||
| SDValue Result = | ||
| DAG.getMemIntrinsicNode(ISD::INTRINSIC_W_CHAIN, DL, VTs, Ops, | ||
| VPNode->getMemoryVT(), VPNode->getMemOperand()); | ||
| SDValue Chain = Result.getValue(1); | ||
| Result = | ||
| DAG.getMemIntrinsicNode(ISD::INTRINSIC_W_CHAIN, DL, VTs, Ops, | ||
| VPNode->getMemoryVT(), VPNode->getMemOperand()); | ||
| Chain = Result.getValue(1); | ||
| } | ||
|
|
||
| if (VT.isFixedLengthVector()) | ||
| Result = convertFromScalableVector(VT, Result, DAG, Subtarget); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.