Skip to content

Commit b63daf6

Browse files
lukel97tru
authored andcommitted
[RISCV] Cost casts with illegal types that can't be legalized (#153030)
If we have a floating point vector and no zve32f/zve64f/zve64d, we can end up with an invalid type-legalization cost from getTypeLegalizationCost. Previously this triggered an assertion that the type must have been legalized if the "legal" type is a vector, but in this case when it's not possible to legalize the original type is spat back out. This fixes it by just checking that the legalization cost is valid. We don't have much testing for zve64x, so we may have other places in the cost model with this issue. Fixes #153008 (cherry picked from commit 81b576e)
1 parent ca11cf3 commit b63daf6

File tree

2 files changed

+2684
-1341
lines changed

2 files changed

+2684
-1341
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,6 +1567,7 @@ InstructionCost RISCVTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
15671567
// scalarized if the legalized Src and Dst are not equal sized.
15681568
const DataLayout &DL = this->getDataLayout();
15691569
if (!SrcLT.second.isVector() || !DstLT.second.isVector() ||
1570+
!SrcLT.first.isValid() || !DstLT.first.isValid() ||
15701571
!TypeSize::isKnownLE(DL.getTypeSizeInBits(Src),
15711572
SrcLT.second.getSizeInBits()) ||
15721573
!TypeSize::isKnownLE(DL.getTypeSizeInBits(Dst),

0 commit comments

Comments
 (0)