[PATCH] D90687: [LV] Ignore VF hint when unsafe
Cullen Rhodes via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 3 08:08:00 PST 2020
c-rhodes created this revision.
c-rhodes added reviewers: sdesmalen, efriedma, fhahn, mkuper, RKSimon, spatel.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
c-rhodes requested review of this revision.
In the following loop the dependence distance is 2 and can only be
vectorized if the vector length is no larger than this.
void foo(int *a, int *b, int N) {
#pragma clang loop vectorize(enable) vectorize_width(4)
for (int i=0; i<N; ++i) {
a[i + 2] = a[i] + b[i];
}
}
However, when specifying a VF of 4 via a loop hint this loop is
vectorized. According to [1][2], loop hints are ignored if the
optimization is not safe to apply.
This patch introduces a check to bail of vectorization if the user
specified VF is greater than the maximum feasible VF, unless explicitly
forced with '-force-vector-width=X'.
[1] https://llvm.org/docs/LangRef.html#llvm-loop-vectorize-and-llvm-loop-interleave
[2] https://clang.llvm.org/docs/LanguageExtensions.html#extensions-for-loop-hint-optimizations
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D90687
Files:
llvm/include/llvm/Analysis/LoopAccessAnalysis.h
llvm/lib/Analysis/LoopAccessAnalysis.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls-VF2-VF8.ll
llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls-finite.ll
llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls.ll
llvm/test/Transforms/LoopVectorize/X86/svml-calls-finite.ll
llvm/test/Transforms/LoopVectorize/metadata-width.ll
llvm/test/Transforms/LoopVectorize/preserve-dbg-loc-and-loop-metadata.ll
llvm/test/Transforms/LoopVectorize/runtime-check.ll
llvm/test/Transforms/LoopVectorize/unsafe-vf-remark.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90687.302584.patch
Type: text/x-patch
Size: 32484 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201103/add0454d/attachment.bin>
More information about the llvm-commits
mailing list