-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[SelectionDAG][X86] Split via Concat <n x T> vector types for atomic load #120640
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
base: users/jofrn/spr/main/2894ccd1
Are you sure you want to change the base?
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 |
---|---|---|
|
@@ -1173,6 +1173,9 @@ void DAGTypeLegalizer::SplitVectorResult(SDNode *N, unsigned ResNo) { | |
SplitVecRes_STEP_VECTOR(N, Lo, Hi); | ||
break; | ||
case ISD::SIGN_EXTEND_INREG: SplitVecRes_InregOp(N, Lo, Hi); break; | ||
case ISD::ATOMIC_LOAD: | ||
SplitVecRes_ATOMIC_LOAD(cast<AtomicSDNode>(N)); | ||
break; | ||
case ISD::LOAD: | ||
SplitVecRes_LOAD(cast<LoadSDNode>(N), Lo, Hi); | ||
break; | ||
|
@@ -1423,6 +1426,36 @@ void DAGTypeLegalizer::SplitVectorResult(SDNode *N, unsigned ResNo) { | |
SetSplitVector(SDValue(N, ResNo), Lo, Hi); | ||
} | ||
|
||
void DAGTypeLegalizer::SplitVecRes_ATOMIC_LOAD(AtomicSDNode *LD) { | ||
SDLoc dl(LD); | ||
|
||
EVT MemoryVT = LD->getMemoryVT(); | ||
unsigned NumElts = MemoryVT.getVectorMinNumElements(); | ||
|
||
EVT IntMemoryVT = EVT::getVectorVT(*DAG.getContext(), MVT::i16, NumElts); | ||
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. Shouldn't be assuming the type. This still should follow allow with SplitVecRes_LOAD, by using GetSplitDestVTs 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 is where the type is coerced so that we load integers. It didn't seem appropriate to split into Lo and Hi here since atomics are different. GetSplitDestVTs will return floats when given a float, but we do not want to load from those (so as to reuse infrastructure), and we want to load the full size at once (not with a split size). |
||
EVT ElemVT = | ||
EVT::getVectorVT(*DAG.getContext(), MemoryVT.getVectorElementType(), 1); | ||
|
||
// Create a single atomic to load all the elements at once. | ||
SDValue Atomic = | ||
DAG.getAtomicLoad(ISD::NON_EXTLOAD, dl, IntMemoryVT, IntMemoryVT, | ||
LD->getChain(), LD->getBasePtr(), | ||
LD->getMemOperand()); | ||
|
||
// Instead of splitting, put all the elements back into a vector. | ||
SmallVector<SDValue, 4> Ops; | ||
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 loop can be replaced with DAG.ExtractVectorElements (but I don't think you should be scalarizing here like this) |
||
for (unsigned i = 0; i < NumElts; ++i) { | ||
SDValue Elt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, MVT::i16, Atomic, | ||
DAG.getVectorIdxConstant(i, dl)); | ||
Elt = DAG.getBitcast(ElemVT, Elt); | ||
Ops.push_back(Elt); | ||
} | ||
SDValue Concat = DAG.getNode(ISD::CONCAT_VECTORS, dl, MemoryVT, Ops); | ||
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 don't think using CONCAT_VECTORS with 2 scale elements is valid. This should be setting the Lo and Hi fields like the other SplitVecRes_* functions do anyway, and not doing manual replacement. Here will need to do manual replacement of the load chain though 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. It is valid like so:
In this way, if t4 is consumed by another concat_vectors, then they can all be combined via EltsFromConsecutiveLoads into a BUILD_VECTOR. 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'd consider this a bug, I would expect this to assert in getNode 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 we may be looking at different things. What do you mean by a 2 scale element being used? The operands to concat_vectors are |
||
|
||
ReplaceValueWith(SDValue(LD, 0), Concat); | ||
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 replacement should be done piecewise in the caller, you should be inserting casting code to satisfy the two DAG.GetSplitDestVTs pieces |
||
ReplaceValueWith(SDValue(LD, 1), LD->getChain()); | ||
} | ||
|
||
void DAGTypeLegalizer::IncrementPointer(MemSDNode *N, EVT MemVT, | ||
MachinePointerInfo &MPI, SDValue &Ptr, | ||
uint64_t *ScaledOffset) { | ||
|
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.
This is missing the Lo / Hi out arguments, like all of the other SplitVecRes cases. You should still be trying to respect the result of DAG.GetSplitDestVTs. With this you are bypassing SetSplitVector
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.
Bump