Skip to content

Commit

Permalink
[SVE] Fix crash when costing getelementptr with scalable target type.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulwalker-arm committed Sep 18, 2023
1 parent b3ca0f3 commit 162bafc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1020,8 +1020,8 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
} else {
// If this operand is a scalable type, bail out early.
// TODO: handle scalable vectors
if (isa<ScalableVectorType>(TargetType))
// TODO: Make isLegalAddressingMode TypeSize aware.
if (TargetType->isScalableTy())
return TTI::TCC_Basic;
int64_t ElementSize =
DL.getTypeAllocSize(GTI.getIndexedType()).getFixedValue();
Expand Down
18 changes: 12 additions & 6 deletions llvm/test/Analysis/CostModel/AArch64/cost-scalable-vector-gep.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@

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

define ptr @gep_scalable_vector(ptr %ptr) {
; CHECK-LABEL: 'gep_scalable_vector'
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %retval = getelementptr <vscale x 16 x i8>, ptr %ptr, i32 2
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret ptr %retval
define void @gep_scalable_types(ptr %ptr) {
; CHECK-LABEL: 'gep_scalable_types'
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %gep1 = getelementptr <vscale x 16 x i8>, ptr %ptr, i32 2
; 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
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %gep3 = getelementptr target("aarch64.svcount"), ptr %ptr, i32 2
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %gep4 = getelementptr [2 x target("aarch64.svcount")], ptr %ptr, i32 2
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
%retval = getelementptr <vscale x 16 x i8>, ptr %ptr, i32 2
ret ptr %retval
%gep1 = getelementptr <vscale x 16 x i8>, ptr %ptr, i32 2
%gep2 = getelementptr [2 x <vscale x 16 x i8>], ptr %ptr, i32 2
%gep3 = getelementptr target("aarch64.svcount"), ptr %ptr, i32 2
%gep4 = getelementptr [2 x target("aarch64.svcount")], ptr %ptr, i32 2
ret void
}

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

0 comments on commit 162bafc

Please sign in to comment.