diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp --- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp +++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp @@ -195,7 +195,18 @@ return BaseT::getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace, CostKind); - return getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, CostKind); + auto LT = TLI->getTypeLegalizationCost(DL, Src); + if (!LT.first.isValid()) + return InstructionCost::getInvalid(); + + // The code-generator is currently not able to handle scalable vectors + // of yet, so return an invalid cost to avoid selecting + // it. This change will be removed when code-generation for these types is + // sufficiently reliable. + if (cast(Src)->getElementCount() == ElementCount::getScalable(1)) + return InstructionCost::getInvalid(); + + return LT.first; } InstructionCost RISCVTTIImpl::getGatherScatterOpCost(