Skip to content

Commit 4a2c05b

Browse files
davemgreentru
authored andcommitted
[ARM] Fix for MVE i128 vector icmp costs.
We were hitting an assert as the legalied type needn't be a vector. Fixes llvm#58364 (cherry picked from commit de6dfbb)
1 parent f6af957 commit 4a2c05b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ InstructionCost ARMTTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
10361036
// split, we may need an expensive shuffle to get two in sync. This has the
10371037
// effect of making larger than legal compares (v8i32 for example)
10381038
// expensive.
1039-
if (LT.second.getVectorNumElements() > 2) {
1039+
if (LT.second.isVector() && LT.second.getVectorNumElements() > 2) {
10401040
if (LT.first > 1)
10411041
return LT.first * BaseCost +
10421042
BaseT::getScalarizationOverhead(VecCondTy, true, false);

llvm/test/Analysis/CostModel/ARM/mve-cmp.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ define void @icmp() {
2222
; CHECK-NEXT: Cost Model: Found an estimated cost of 36 for instruction: %v2i64 = icmp slt <2 x i64> undef, undef
2323
; CHECK-NEXT: Cost Model: Found an estimated cost of 72 for instruction: %v4i64 = icmp slt <4 x i64> undef, undef
2424
; CHECK-NEXT: Cost Model: Found an estimated cost of 144 for instruction: %v8i64 = icmp slt <8 x i64> undef, undef
25+
; CHECK-NEXT: Cost Model: Found an estimated cost of 68 for instruction: %v2i128 = icmp slt <2 x i128> undef, undef
26+
; CHECK-NEXT: Cost Model: Found an estimated cost of 136 for instruction: %v4i128 = icmp slt <4 x i128> undef, undef
2527
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
2628
;
2729
%v2i8 = icmp slt <2 x i8> undef, undef
@@ -44,6 +46,9 @@ define void @icmp() {
4446
%v4i64 = icmp slt <4 x i64> undef, undef
4547
%v8i64 = icmp slt <8 x i64> undef, undef
4648

49+
%v2i128 = icmp slt <2 x i128> undef, undef
50+
%v4i128 = icmp slt <4 x i128> undef, undef
51+
4752
ret void
4853
}
4954

0 commit comments

Comments
 (0)