Skip to content

Commit fb034f0

Browse files
committed
[LoopVectorizer] Add a -force-vscale-for-tuning override option.
It can be useful for debugging and tuning to be able to alter the VScaleForTuning. This adds a quick option to the vectorizer for it
1 parent 3bdd397 commit fb034f0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ static cl::opt<bool> ForceTargetSupportsScalableVectors(
294294
"Pretend that scalable vectors are supported, even if the target does "
295295
"not support them. This flag should only be used for testing."));
296296

297+
static cl::opt<unsigned> VScaleForTuningOpt(
298+
"force-vscale-for-tuning", cl::Hidden,
299+
cl::desc("Force a vscale for tuning factor in the loop vectorizer"));
300+
297301
static cl::opt<unsigned> SmallLoopCost(
298302
"small-loop-cost", cl::init(20), cl::Hidden,
299303
cl::desc(
@@ -1463,6 +1467,11 @@ class LoopVectorizationCostModel {
14631467
/// vscale_range.min == vscale_range.max then return vscale_range.max, else
14641468
/// return the value returned by the corresponding TTI method.
14651469
void initializeVScaleForTuning() {
1470+
if (VScaleForTuningOpt.getNumOccurrences()) {
1471+
VScaleForTuning = VScaleForTuningOpt;
1472+
return;
1473+
}
1474+
14661475
const Function *Fn = TheLoop->getHeader()->getParent();
14671476
if (Fn->hasFnAttribute(Attribute::VScaleRange)) {
14681477
auto Attr = Fn->getFnAttribute(Attribute::VScaleRange);

llvm/test/Transforms/LoopVectorize/AArch64/scalable-vectorization-cost-tuning.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
; RUN: -force-target-instruction-cost=1 -passes=loop-vectorize -S -debug-only=loop-vectorize --disable-output < %s 2>&1 \
88
; RUN: | FileCheck %s --check-prefixes=VSCALEFORTUNING1
99

10+
; RUN: opt -mtriple=aarch64 -mattr=+sve -mcpu=generic -force-vscale-for-tuning=2 \
11+
; RUN: -force-target-instruction-cost=1 -passes=loop-vectorize -S -debug-only=loop-vectorize --disable-output < %s 2>&1 \
12+
; RUN: | FileCheck %s --check-prefixes=VSCALEFORTUNING2
13+
1014
; RUN: opt -mtriple=aarch64 -mcpu=neoverse-v1 \
1115
; RUN: -force-target-instruction-cost=1 -passes=loop-vectorize -S -debug-only=loop-vectorize --disable-output < %s 2>&1 \
1216
; RUN: | FileCheck %s --check-prefixes=VSCALEFORTUNING2

0 commit comments

Comments
 (0)