Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp =================================================================== --- llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp +++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp @@ -14,7 +14,7 @@ static int getInstSeqCost(RISCVMatInt::InstSeq &Res, bool HasRVC) { if (!HasRVC) - return Res.size(); + return Res.size() * 100; int Cost = 0; for (auto Instr : Res) { @@ -381,7 +381,7 @@ int getIntMatCost(const APInt &Val, unsigned Size, const FeatureBitset &ActiveFeatures, bool CompressionCost) { bool IsRV64 = ActiveFeatures[RISCV::Feature64Bit]; - bool HasRVC = CompressionCost && ActiveFeatures[RISCV::FeatureStdExtC]; + bool HasRVC = ActiveFeatures[RISCV::FeatureStdExtC]; int PlatRegSize = IsRV64 ? 64 : 32; // Split the constant into platform register sized chunks, and calculate cost @@ -390,9 +390,16 @@ for (unsigned ShiftVal = 0; ShiftVal < Size; ShiftVal += PlatRegSize) { APInt Chunk = Val.ashr(ShiftVal).sextOrTrunc(PlatRegSize); InstSeq MatSeq = generateInstSeq(Chunk.getSExtValue(), ActiveFeatures); - Cost += getInstSeqCost(MatSeq, HasRVC); + if (CompressionCost) + Cost += getInstSeqCost(MatSeq, HasRVC); + else + Cost += MatSeq.size(); } - return std::max(1, Cost); + + if (CompressionCost) + return Cost; + else + return std::max(1, Cost); } OpndKind Inst::getOpndKind() const {