Skip to content

Commit 162bafc

Browse files
[SVE] Fix crash when costing getelementptr with scalable target type.
Fixes llvm#66594
1 parent b3ca0f3 commit 162bafc

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,8 +1020,8 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
10201020
BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
10211021
} else {
10221022
// If this operand is a scalable type, bail out early.
1023-
// TODO: handle scalable vectors
1024-
if (isa<ScalableVectorType>(TargetType))
1023+
// TODO: Make isLegalAddressingMode TypeSize aware.
1024+
if (TargetType->isScalableTy())
10251025
return TTI::TCC_Basic;
10261026
int64_t ElementSize =
10271027
DL.getTypeAllocSize(GTI.getIndexedType()).getFixedValue();

llvm/test/Analysis/CostModel/AArch64/cost-scalable-vector-gep.ll

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@
77

88
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
99

10-
define ptr @gep_scalable_vector(ptr %ptr) {
11-
; CHECK-LABEL: 'gep_scalable_vector'
12-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %retval = getelementptr <vscale x 16 x i8>, ptr %ptr, i32 2
13-
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret ptr %retval
10+
define void @gep_scalable_types(ptr %ptr) {
11+
; CHECK-LABEL: 'gep_scalable_types'
12+
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %gep1 = getelementptr <vscale x 16 x i8>, ptr %ptr, i32 2
13+
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %gep2 = getelementptr [2 x <vscale x 16 x i8>], ptr %ptr, i32 2
14+
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %gep3 = getelementptr target("aarch64.svcount"), ptr %ptr, i32 2
15+
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %gep4 = getelementptr [2 x target("aarch64.svcount")], ptr %ptr, i32 2
16+
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
1417
;
15-
%retval = getelementptr <vscale x 16 x i8>, ptr %ptr, i32 2
16-
ret ptr %retval
18+
%gep1 = getelementptr <vscale x 16 x i8>, ptr %ptr, i32 2
19+
%gep2 = getelementptr [2 x <vscale x 16 x i8>], ptr %ptr, i32 2
20+
%gep3 = getelementptr target("aarch64.svcount"), ptr %ptr, i32 2
21+
%gep4 = getelementptr [2 x target("aarch64.svcount")], ptr %ptr, i32 2
22+
ret void
1723
}
1824

1925
define ptr @sext_gep(ptr %p, i32 %a) {

0 commit comments

Comments
 (0)