-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[X86] Merge insertsubvector(load(p0),load_subv(p0),hi) -> subvbroadcast(p0) if either load is oneuse #128857
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
[X86] Merge insertsubvector(load(p0),load_subv(p0),hi) -> subvbroadcast(p0) if either load is oneuse #128857
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 |
---|---|---|
|
@@ -58567,15 +58567,22 @@ static SDValue combineINSERT_SUBVECTOR(SDNode *N, SelectionDAG &DAG, | |
|
||
// If we're splatting the lower half subvector of a full vector load into the | ||
// upper half, attempt to create a subvector broadcast. | ||
if (IdxVal == (OpVT.getVectorNumElements() / 2) && SubVec.hasOneUse() && | ||
Vec.getValueSizeInBits() == (2 * SubVec.getValueSizeInBits())) { | ||
// TODO: Drop hasOneUse checks. | ||
if (IdxVal == (OpVT.getVectorNumElements() / 2) && | ||
Vec.getValueSizeInBits() == (2 * SubVec.getValueSizeInBits()) && | ||
(Vec.hasOneUse() || SubVec.hasOneUse())) { | ||
auto *VecLd = dyn_cast<LoadSDNode>(Vec); | ||
auto *SubLd = dyn_cast<LoadSDNode>(SubVec); | ||
if (VecLd && SubLd && | ||
DAG.areNonVolatileConsecutiveLoads(SubLd, VecLd, | ||
SubVec.getValueSizeInBits() / 8, 0)) | ||
return getBROADCAST_LOAD(X86ISD::SUBV_BROADCAST_LOAD, dl, OpVT, SubVecVT, | ||
SubLd, 0, DAG); | ||
DAG.areNonVolatileConsecutiveLoads( | ||
SubLd, VecLd, SubVec.getValueSizeInBits() / 8, 0)) { | ||
SDValue BcastLd = getBROADCAST_LOAD(X86ISD::SUBV_BROADCAST_LOAD, dl, OpVT, | ||
SubVecVT, SubLd, 0, DAG); | ||
SDValue NewSubVec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, SubVecVT, | ||
BcastLd, DAG.getVectorIdxConstant(0, dl)); | ||
DCI.CombineTo(SubLd, NewSubVec, BcastLd.getValue(1)); | ||
Comment on lines
+58581
to
+58583
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. This only required when 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. we don't need the check, oneuse cases will be handled fine, but it might slightly improve perf 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. its easier if we always call it, just in case there's weird cases like only Subvec's chain is still in use. |
||
return BcastLd; | ||
} | ||
} | ||
|
||
return SDValue(); | ||
|
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.
Does
Vec
have oneuse matter? Can't the loaded value be used more than once?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.
Let me see if I can get this to always replace uses of subvec - then we can get rid of the oneuse checks entirely
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.
The oneuse checks are still preventing some regressions due to shouldReduceLoadWidth being so permissive, but I've at least ensured that any other uses of SubVec are replaced now.