aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Walker <paul.walker@arm.com>2023-09-18 12:34:08 +0000
committerPaul Walker <paul.walker@arm.com>2023-09-18 12:48:30 +0000
commit162bafc8b7a9f25f793bd58c7348e4c94b4a0a84 (patch)
treea81b0c281a4ab75f1d3929d6d2a1f47994b70dd1
parentb3ca0f34cfc6ec267039d275021e8364c866b7ac (diff)
downloadllvm-162bafc8b7a9f25f793bd58c7348e4c94b4a0a84.zip
llvm-162bafc8b7a9f25f793bd58c7348e4c94b4a0a84.tar.gz
llvm-162bafc8b7a9f25f793bd58c7348e4c94b4a0a84.tar.bz2
[SVE] Fix crash when costing getelementptr with scalable target type.
Fixes #66594
-rw-r--r--llvm/include/llvm/Analysis/TargetTransformInfoImpl.h4
-rw-r--r--llvm/test/Analysis/CostModel/AArch64/cost-scalable-vector-gep.ll18
2 files changed, 14 insertions, 8 deletions
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index 4ab3399..326c313 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -1020,8 +1020,8 @@ public:
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();
diff --git a/llvm/test/Analysis/CostModel/AArch64/cost-scalable-vector-gep.ll b/llvm/test/Analysis/CostModel/AArch64/cost-scalable-vector-gep.ll
index 2666d87..7c16ab4 100644
--- a/llvm/test/Analysis/CostModel/AArch64/cost-scalable-vector-gep.ll
+++ b/llvm/test/Analysis/CostModel/AArch64/cost-scalable-vector-gep.ll
@@ -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) {