[PATCH] D137159: [LoopVectorize] Introduce CanSinkMemoryInstrs to isFixedOrderRecurrence
Peter Waller via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 1 06:33:59 PDT 2022
peterwaller-arm created this revision.
Herald added subscribers: shiva0217, hiraditya.
Herald added a project: All.
peterwaller-arm requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead.
Herald added a project: LLVM.
Given a loop of the form:
double w[1024], x[1024], a[1024];
void f() {
for (unsigned i = 0; i < 1024-1; i++) {
w[i] += a[i];
x[i] += a[i+1];
}
}
Currently GVN PRE creates a phi which feeds a[i+1] into the next
iteration.
Prior to this patch, this phi is reported as being 'unknown':
remark: loop not vectorized: value that could not be identified as
reduction is used outside the loop [-Rpass-analysis=loop-vectorize]
w[i] += a[i];
^
The reason is that isFixedOrderRecurrence sees the store to w[i]
occurring before the read from a[i+1] and it knows nothing about how
these are related.
This patch introduces a query for the memory dependences of the phi
input. If the memory dependency analysis reports a nonlocal dependency,
then any memory instructions can be sunk past it.
NOTE: I'm putting this patch up for early comments. Some things I'm
currently continuing to look into: Does LoopVectorize need the
memory dependence analysis, or is there other infrastructure available
that can be reused? Can I find any examples of miscompiles and does it
have the desired benchmarking impact?
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D137159
Files:
llvm/lib/Analysis/IVDescriptors.cpp
llvm/test/Transforms/LoopVectorize/AArch64/fixed-order-recurrence.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137159.472276.patch
Type: text/x-patch
Size: 7949 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221101/564d49e7/attachment.bin>
More information about the llvm-commits
mailing list