Skip to content

Commit 81b576e

Browse files
authored
[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
1 parent 7b41c2f commit 81b576e

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
@@ -1629,6 +1629,7 @@ InstructionCost RISCVTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
16291629
// scalarized if the legalized Src and Dst are not equal sized.
16301630
const DataLayout &DL = this->getDataLayout();
16311631
if (!SrcLT.second.isVector() || !DstLT.second.isVector() ||
1632+
!SrcLT.first.isValid() || !DstLT.first.isValid() ||
16321633
!TypeSize::isKnownLE(DL.getTypeSizeInBits(Src),
16331634
SrcLT.second.getSizeInBits()) ||
16341635
!TypeSize::isKnownLE(DL.getTypeSizeInBits(Dst),

0 commit comments

Comments
 (0)