Skip to content

Commit 660ab72

Browse files
lukel97MarkMurrayARM
authored andcommitted
Automerge: [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)
2 parents 4916cae + b63daf6 commit 660ab72

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)