Skip to content

Commit b4b4904

Browse files
authored
[RISCV] Fix insert_subvector with fixed vector type creating invalid node (#82975)
If the vector type is a fixed vector type, we convert it to a container scalable vector type to compute its reg class. But we need to keep the old fixed type so we create a result node with the same type. This code path is currently dead so I haven't been able to create a test case for it. But I have an upcoming patch for insert_subvector lowering that will exercise this.
1 parent bb87c91 commit b4b4904

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,14 +2066,15 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
20662066
assert(Idx == 0 && V.isUndef());
20672067
SubVecContainerVT = TLI.getContainerForFixedLengthVector(SubVecVT);
20682068
}
2069+
MVT ContainerVT = VT;
20692070
if (VT.isFixedLengthVector())
2070-
VT = TLI.getContainerForFixedLengthVector(VT);
2071+
ContainerVT = TLI.getContainerForFixedLengthVector(VT);
20712072

20722073
const auto *TRI = Subtarget->getRegisterInfo();
20732074
unsigned SubRegIdx;
20742075
std::tie(SubRegIdx, Idx) =
20752076
RISCVTargetLowering::decomposeSubvectorInsertExtractToSubRegs(
2076-
VT, SubVecContainerVT, Idx, TRI);
2077+
ContainerVT, SubVecContainerVT, Idx, TRI);
20772078

20782079
// If the Idx hasn't been completely eliminated then this is a subvector
20792080
// insert which doesn't naturally align to a vector register. These must
@@ -2093,7 +2094,8 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
20932094
// If we haven't set a SubRegIdx, then we must be going between
20942095
// equally-sized LMUL groups (e.g. VR -> VR). This can be done as a copy.
20952096
if (SubRegIdx == RISCV::NoSubRegister) {
2096-
unsigned InRegClassID = RISCVTargetLowering::getRegClassIDForVecVT(VT);
2097+
unsigned InRegClassID =
2098+
RISCVTargetLowering::getRegClassIDForVecVT(ContainerVT);
20972099
assert(RISCVTargetLowering::getRegClassIDForVecVT(SubVecContainerVT) ==
20982100
InRegClassID &&
20992101
"Unexpected subvector extraction");

0 commit comments

Comments
 (0)