diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h index 4ab33995618213..326c3130c6cff7 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(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 2666d8756d716e..7c16ab41bf3692 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 , 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 , ptr %ptr, i32 2 +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %gep2 = getelementptr [2 x ], 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 , ptr %ptr, i32 2 - ret ptr %retval + %gep1 = getelementptr , ptr %ptr, i32 2 + %gep2 = getelementptr [2 x ], 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) {