[llvm] 162bafc - [SVE] Fix crash when costing getelementptr with scalable target type.
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 18 05:50:12 PDT 2023
Author: Paul Walker
Date: 2023-09-18T12:48:30Z
New Revision: 162bafc8b7a9f25f793bd58c7348e4c94b4a0a84
URL: https://github.com/llvm/llvm-project/commit/162bafc8b7a9f25f793bd58c7348e4c94b4a0a84
DIFF: https://github.com/llvm/llvm-project/commit/162bafc8b7a9f25f793bd58c7348e4c94b4a0a84.diff
LOG: [SVE] Fix crash when costing getelementptr with scalable target type.
Fixes #66594
Added:
Modified:
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/test/Analysis/CostModel/AArch64/cost-scalable-vector-gep.ll
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index 4ab33995618213c..326c3130c6cff76 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -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();
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 2666d8756d716eb..7c16ab41bf3692f 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) {
More information about the llvm-commits
mailing list