-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[RISCV][TTI] Fix crash of non-built-in vector type cost quering. #167258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-llvm-analysis @llvm/pr-subscribers-backend-risc-v Author: Elvis Wang (ElvisWang123) ChangesFor the non-built-in vector type, the RISCV cost model cannot handle this properly. Fixes: #166732 Full diff: https://github.com/llvm/llvm-project/pull/167258.diff 2 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index 7bc0b5b394828..73387b4999898 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -1683,7 +1683,8 @@ InstructionCost RISCVTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
!TypeSize::isKnownLE(DL.getTypeSizeInBits(Src),
SrcLT.second.getSizeInBits()) ||
!TypeSize::isKnownLE(DL.getTypeSizeInBits(Dst),
- DstLT.second.getSizeInBits()))
+ DstLT.second.getSizeInBits()) ||
+ SrcLT.first > 1 || DstLT.first > 1)
return BaseT::getCastInstrCost(Opcode, Dst, Src, CCH, CostKind, I);
// The split cost is handled by the base getCastInstrCost
diff --git a/llvm/test/Analysis/CostModel/RISCV/cast.ll b/llvm/test/Analysis/CostModel/RISCV/cast.ll
index e64bce2d9c9e5..c67702cf8238f 100644
--- a/llvm/test/Analysis/CostModel/RISCV/cast.ll
+++ b/llvm/test/Analysis/CostModel/RISCV/cast.ll
@@ -6239,3 +6239,13 @@ define void @legalization_crash() {
fptoui <192 x float> undef to <192 x i1>
ret void
}
+
+; Test that BitInt cases won't crash at cost model.
+define void @BitInt_crash() {
+; ZVE64X-LABEL: 'BitInt_crash'
+; ZVE64X-NEXT: Cost Model: Found an estimated cost of 2043 for instruction: %1 = bitcast <16 x i64> undef to <512 x i2>
+; ZVE64X-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
+;
+ bitcast <16 x i64> undef to <512 x i2>
+ ret void
+}
|
|
✅ With the latest revision this PR passed the undef deprecator. |
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: llvm#166732
05c8fb9 to
96eaa94
Compare
lukel97
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| @@ -6239,3 +6239,13 @@ define void @legalization_crash() { | |||
| fptoui <192 x float> undef to <192 x i1> | |||
| ret void | |||
| } | |||
|
|
|||
| ; Test that BitInt cases won't crash at cost model. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, maybe say that this is testing cases where one of the types needs to be split?
| ; Test that BitInt cases won't crash at cost model. | |
| ; Test that types that need to be split go through BasicTTIImpl |
XChy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks.
For the non-built-in vector type, the RISCV cost model cannot handle this properly.
So fall back to the BasicTTI for this situation.
Fixes: #166732