Skip to content

Commit 96eaa94

Browse files
committed
[RISCV][TTI] Fix crash of non-built-in vector type cost quering.
For the non-built-in vector type, the RISCV cost model cannot handle this propely. So fall back to the BasicTTI for this situation. Fixes: #166732
1 parent 902b0bd commit 96eaa94

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,8 @@ InstructionCost RISCVTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
16831683
!TypeSize::isKnownLE(DL.getTypeSizeInBits(Src),
16841684
SrcLT.second.getSizeInBits()) ||
16851685
!TypeSize::isKnownLE(DL.getTypeSizeInBits(Dst),
1686-
DstLT.second.getSizeInBits()))
1686+
DstLT.second.getSizeInBits()) ||
1687+
SrcLT.first > 1 || DstLT.first > 1)
16871688
return BaseT::getCastInstrCost(Opcode, Dst, Src, CCH, CostKind, I);
16881689

16891690
// The split cost is handled by the base getCastInstrCost

llvm/test/Analysis/CostModel/RISCV/cast.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6239,3 +6239,13 @@ define void @legalization_crash() {
62396239
fptoui <192 x float> undef to <192 x i1>
62406240
ret void
62416241
}
6242+
6243+
; Test that BitInt cases won't crash at cost model.
6244+
define void @BitInt_crash() {
6245+
; ZVE64X-LABEL: 'BitInt_crash'
6246+
; ZVE64X-NEXT: Cost Model: Found an estimated cost of 2043 for instruction: %1 = bitcast <16 x i64> poison to <512 x i2>
6247+
; ZVE64X-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
6248+
;
6249+
bitcast <16 x i64> poison to <512 x i2>
6250+
ret void
6251+
}

0 commit comments

Comments
 (0)