[llvm] [RISCV] Fix insert_subvector with fixed vector type creating invalid node (PR #82975)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 26 01:58:48 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-risc-v
Author: Luke Lau (lukel97)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/82975.diff
1 Files Affected:
- (modified) llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp (+5-3)
``````````diff
diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
index c922098c55094e..1b8c1434c9f2d9 100644
--- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -2066,14 +2066,15 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
assert(Idx == 0 && V.isUndef());
SubVecContainerVT = TLI.getContainerForFixedLengthVector(SubVecVT);
}
+ MVT ContainerVT = VT;
if (VT.isFixedLengthVector())
- VT = TLI.getContainerForFixedLengthVector(VT);
+ ContainerVT = TLI.getContainerForFixedLengthVector(VT);
const auto *TRI = Subtarget->getRegisterInfo();
unsigned SubRegIdx;
std::tie(SubRegIdx, Idx) =
RISCVTargetLowering::decomposeSubvectorInsertExtractToSubRegs(
- VT, SubVecContainerVT, Idx, TRI);
+ ContainerVT, SubVecContainerVT, Idx, TRI);
// If the Idx hasn't been completely eliminated then this is a subvector
// insert which doesn't naturally align to a vector register. These must
@@ -2093,7 +2094,8 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
// If we haven't set a SubRegIdx, then we must be going between
// equally-sized LMUL groups (e.g. VR -> VR). This can be done as a copy.
if (SubRegIdx == RISCV::NoSubRegister) {
- unsigned InRegClassID = RISCVTargetLowering::getRegClassIDForVecVT(VT);
+ unsigned InRegClassID =
+ RISCVTargetLowering::getRegClassIDForVecVT(ContainerVT);
assert(RISCVTargetLowering::getRegClassIDForVecVT(SubVecContainerVT) ==
InRegClassID &&
"Unexpected subvector extraction");
``````````
</details>
https://github.com/llvm/llvm-project/pull/82975
More information about the llvm-commits
mailing list