[llvm] [AMDGPU] In VectorLegalizer::Expand, if UnrollVectorOp returns Load, … (PR #88475)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 12 14:52:10 PDT 2024
================
@@ -1159,8 +1159,12 @@ void VectorLegalizer::Expand(SDNode *Node, SmallVectorImpl<SDValue> &Results) {
}
SDValue Unrolled = DAG.UnrollVectorOp(Node);
- for (unsigned I = 0, E = Unrolled->getNumValues(); I != E; ++I)
- Results.push_back(Unrolled.getValue(I));
+ const LoadSDNode *Ld = dyn_cast<LoadSDNode>(Unrolled.getNode());
+ if (Ld)
+ Results.push_back(Unrolled);
+ else
+ for (unsigned I = 0, E = Unrolled->getNumValues(); I != E; ++I)
+ Results.push_back(Unrolled.getValue(I));
----------------
topperc wrote:
Well even that's not technically right. If there is a single result expected, we shouldn't call getValue we should use the SDValue directly as the result. Folding might have allowed the SDValue to point to one result of a node with multiple results where the desired result isn't result 0.
If multiple results are expected, it should be a MERGE_VALUES node which isn't subject to folding.
Something like this is probably closer to correct.
```
if (Node->getValues() == 1) {
// Only 1 result expect, use it directly. It isn't guaranteed to be result 0.
Results.push_back(Unrolled);
} else {
assert(Node->getValues() > 1);
assert(Unrolled->getOpcode() == ISD::MERGE_VALUES);
for (unsigned I = 0, E = Node->getNumValues(); I != E; ++I)
Results.push_back(Unrolled.getValue(I));
}
```
https://github.com/llvm/llvm-project/pull/88475
More information about the llvm-commits
mailing list