diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h --- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h +++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h @@ -56,7 +56,6 @@ bool shouldExpandReduction(const IntrinsicInst *II) const; bool supportsScalableVectors() const { return ST->hasVInstructions(); } - bool enableScalableVectorization() const { return ST->hasVInstructions(); } Optional getMaxVScale() const; TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const { 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 @@ -164,10 +164,10 @@ } InstructionCost RISCVTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst, - Type *Src, - TTI::CastContextHint CCH, - TTI::TargetCostKind CostKind, - const Instruction *I) { + Type *Src, + TTI::CastContextHint CCH, + TTI::TargetCostKind CostKind, + const Instruction *I) { int ISD = TLI->InstructionOpcodeToISD(Opcode); assert(ISD && "Invalid opcode"); @@ -187,7 +187,8 @@ if (ISD == ISD::ZERO_EXTEND && SrcTy.isScalableVector() && DstTy.isScalableVector()) { - if (SrcTy.isInteger() && DstTy.isInteger()) { + if (SrcTy.isInteger() && DstTy.isInteger() && + SrcTy.getVectorElementCount() == DstTy.getVectorElementCount()) { if (SrcTy.getScalarSizeInBits() <= DstTy.getScalarSizeInBits()) { return 0; } @@ -196,7 +197,6 @@ return AdjustCost( BaseT::getCastInstrCost(Opcode, Dst, Src, CCH, CostKind, I)); - } void RISCVTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,