[llvm] [RISCV] Model interleave2 and deinterleave2 costs with Zvzip (PR #225752)
Ryan Buchner via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 29 01:26:45 PDT 2026
================
@@ -733,6 +733,48 @@ InstructionCost RISCVTTIImpl::getSlideCost(FixedVectorType *Tp,
return FirstSlideCost + SecondSlideCost + MaskCost;
}
+std::optional<MVT> RISCVTTIImpl::getZvzipVZIPCostVT(MVT InterleavedVT) const {
+ if (!InterleavedVT.getVectorElementCount().isKnownEven())
+ return std::nullopt;
+
+ MVT CostVT = InterleavedVT;
+ if (InterleavedVT.isFixedLengthVector()) {
+ MVT SourceVT = InterleavedVT.getHalfNumVectorElementsVT();
+ CostVT = TLI->getContainerForFixedLengthVector(SourceVT)
+ .getDoubleNumVectorElementsVT();
+ }
+
+ unsigned EltBits = CostVT.getScalarSizeInBits();
+ unsigned MinSize = CostVT.getSizeInBits().getKnownMinValue();
+ unsigned LMULOctuple = MinSize / (RISCV::RVVBitsPerBlock / 8);
+ // Perform the 2 * SEW <= LMUL * min(ELEN, VLEN) check.
+ if (EltBits * 16 >
+ LMULOctuple * std::min(ST->getELen(), ST->getRealMinVLen()))
+ return std::nullopt;
+ return CostVT;
+}
+
+std::optional<MVT> RISCVTTIImpl::getZvzipVUNZIPCostVT(MVT InterleavedVT) const {
+ if (!InterleavedVT.getVectorElementCount().isKnownEven())
+ return std::nullopt;
+
+ MVT CostVT = InterleavedVT;
+ // lowerZvzipVUNZIP widens the source container if halving it would produce
+ // an illegal result type. Apply the same rule here so the cost uses the
+ // source LMUL selected by ISel.
+ if (InterleavedVT.isFixedLengthVector()) {
+ CostVT = TLI->getContainerForFixedLengthVector(InterleavedVT);
+ if (CostVT.getVectorMinNumElements() == 1 ||
+ !TLI->isTypeLegal(CostVT.getHalfNumVectorElementsVT()))
+ CostVT = CostVT.getDoubleNumVectorElementsVT();
+ }
----------------
bababuck wrote:
Thanks for splitting it up!
https://github.com/llvm/llvm-project/pull/225752
More information about the llvm-commits
mailing list