[llvm] [RISCV][TTI] Add checks for invalid cast operations (PR #88854)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 16 10:19:30 PDT 2024
================
@@ -956,6 +956,9 @@ InstructionCost RISCVTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
return getRISCVInstructionCost(Op, DstLT.second, CostKind);
}
case ISD::TRUNCATE:
+ // Early return for invalid operation
+ if (Dst->getScalarSizeInBits() >= Src->getScalarSizeInBits())
+ break;
if (Dst->getScalarSizeInBits() == 1) {
----------------
topperc wrote:
Don't repeatedly call getScalarSizeInBits on the same object. Use a variable.
https://github.com/llvm/llvm-project/pull/88854
More information about the llvm-commits
mailing list