diff --git a/src/arith/const_int_bound.cc b/src/arith/const_int_bound.cc index 76c97c5ad5bf..2f9d640ee712 100644 --- a/src/arith/const_int_bound.cc +++ b/src/arith/const_int_bound.cc @@ -371,7 +371,9 @@ class ConstIntBoundAnalyzer::Impl } else if (op->op.same_as(tir::builtin::bitwise_and())) { return VisitBitwiseAnd(op); } else if (op->op.same_as(tir::builtin::vscale()) && TargetHasSVE()) { - return MakeBound(1, kAArch64VScaleValues.size()); + unsigned int max_val = + *std::max_element(kAArch64VScaleValues.begin(), kAArch64VScaleValues.end()); + return MakeBound(1, max_val); } else { return Everything(op->dtype); } diff --git a/src/arith/scalable_expression.h b/src/arith/scalable_expression.h index 800d920fb707..8e807eb3b839 100644 --- a/src/arith/scalable_expression.h +++ b/src/arith/scalable_expression.h @@ -35,8 +35,7 @@ namespace tvm { namespace arith { /*! \brief A list of known vscale values to try for an AArch64 SVE target. */ -static const std::vector kAArch64VScaleValues = {1, 2, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15, 16}; +static const std::vector kAArch64VScaleValues = {1, 2, 4, 8, 16}; /*! * \brief Check if an expr is a call to the vscale intrinsic. diff --git a/src/target/llvm/codegen_aarch64.cc b/src/target/llvm/codegen_aarch64.cc index 785c45457e60..2510c8bd772b 100644 --- a/src/target/llvm/codegen_aarch64.cc +++ b/src/target/llvm/codegen_aarch64.cc @@ -57,8 +57,10 @@ void CodeGenAArch64::SetTargetAttributes(llvm::Function* func) { #if TVM_LLVM_VERSION >= 130 // Add vscale_range() function attribute when appropriate. if (llvm_target_->TargetHasCPUFeature("sve") || llvm_target_->TargetHasCPUFeature("sme")) { - func->addFnAttr(llvm::Attribute::getWithVScaleRangeArgs( - *llvm_target_->GetContext(), 1, tvm::arith::kAArch64VScaleValues.size())); + unsigned int max_val = + *std::max_element(arith::kAArch64VScaleValues.begin(), arith::kAArch64VScaleValues.end()); + func->addFnAttr( + llvm::Attribute::getWithVScaleRangeArgs(*llvm_target_->GetContext(), 1, max_val)); } #endif CodeGenCPU::SetTargetAttributes(func);