[llvm-branch-commits] [llvm] [RISCV] Return cost for scalable compressstore/expandload intrinsics (PR #225143)

Luke Lau via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Sep 24 03:46:06 PDT 2026


================
@@ -3491,30 +3491,34 @@ bool RISCVTTIImpl::isLSRCostLess(const TargetTransformInfo::LSRCost &C1,
 bool RISCVTTIImpl::isLegalMaskedExpandLoad(Type *DataTy,
                                            Align Alignment) const {
   auto *VTy = dyn_cast<VectorType>(DataTy);
-  if (!VTy || VTy->isScalableTy())
+  if (!VTy)
     return false;
 
   if (!isLegalMaskedLoadStore(DataTy, Alignment))
     return false;
 
   // FIXME: If it is an i8 vector and the element count exceeds 256, we should
   // scalarize these types with LMUL >= maximum fixed-length LMUL.
-  if (VTy->getElementType()->isIntegerTy(8))
-    if (VTy->getElementCount().getFixedValue() > 256)
-      return VTy->getPrimitiveSizeInBits() / ST->getRealMinVLen() <
-             ST->getMaxLMULForFixedLengthVectors();
+  if (VTy->getElementType()->isIntegerTy(8)) {
+    uint64_t MaxEltCount = VTy->getElementCount().getKnownMinValue();
+    if (VTy->isScalableTy())
+      MaxEltCount *= ST->getRealMaxVLen() / RISCV::RVVBitsPerBlock;
+    if (MaxEltCount > 256) {
+      uint64_t LMUL;
+      if (VTy->isScalableTy())
+        LMUL = VTy->getPrimitiveSizeInBits().getKnownMinValue() /
+               RISCV::RVVBitsPerBlock;
+      else
+        LMUL = VTy->getPrimitiveSizeInBits() / ST->getRealMinVLen();
+      return LMUL < ST->getMaxLMULForFixedLengthVectors();
----------------
lukel97 wrote:

Agreed, reworked to use getTypeLegalizationCost and just check the legalization cost instead in 36aa7ea11f8cbf7ed812b4ccd4a04d900260f24f

https://github.com/llvm/llvm-project/pull/225143


More information about the llvm-branch-commits mailing list