Skip to content

Commit 3cee43e

Browse files
committed
Add asserts that the subvector size is a power of 2
This is an invariant needed if we want to check that the subvector exactly fills a vector register by checking if it's a multiple of vlen.
1 parent 1a1a661 commit 3cee43e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,6 +2105,8 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
21052105
bool ExactlyVecRegSized =
21062106
Subtarget->expandVScale(SubVecVT.getSizeInBits())
21072107
.isKnownMultipleOf(Subtarget->expandVScale(VecRegSize));
2108+
assert(isPowerOf2_64(Subtarget->expandVScale(SubVecVT.getSizeInBits())
2109+
.getKnownMinValue()));
21082110
assert(Idx == 0 && (ExactlyVecRegSized || V.isUndef()));
21092111
#endif
21102112
}

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9861,6 +9861,8 @@ SDValue RISCVTargetLowering::lowerINSERT_SUBVECTOR(SDValue Op,
98619861
}
98629862

98639863
TypeSize VecRegSize = TypeSize::getScalable(RISCV::RVVBitsPerBlock);
9864+
assert(isPowerOf2_64(
9865+
Subtarget.expandVScale(SubVecVT.getSizeInBits()).getKnownMinValue()));
98649866
bool ExactlyVecRegSized =
98659867
Subtarget.expandVScale(SubVecVT.getSizeInBits())
98669868
.isKnownMultipleOf(Subtarget.expandVScale(VecRegSize));

0 commit comments

Comments
 (0)