[PATCH] D119078: [LAA, LV] Add initial support for pointer-diff memory checks (WIP).

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 6 06:08:32 PST 2022


fhahn created this revision.
Herald added subscribers: dmgreen, hiraditya.
fhahn requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch adds initial support for a pointer diff based runtime check
scheme for vectorization. This scheme requires fewer computations and
checks than the existing full overlap checking, if it is applicable.

The main idea is to only check if source and sink of a dependency are
far enough apart so the accesses won't overlap in the vector loop. To do
so, it is sufficient to compute the difference and compare it to the VF

- UF * AccessSize. It is sufficient to check

`(Sink - Src) <u VF * UF * AccessSize` to rule out a backwards
dependence in the vector loop with the given VF and UF. If Src >=u Sink,
there is not dependence preventing vectorization, hence the overflow
should not matter and using the ULT should be sufficient.

Note that the initial version is restricted in multiple ways:

  1. Pointers must only either be read or written, by a single instruction (this allows re-constructing source/sink for dependences with the available information)
1. Source and sink pointers must be add-recs, with matching steps
2. The step must be a constant.
3. abs(step) == AccessSize.

Most of those restrictions can be relaxed in the future.

The part of the code that connects the information from
DependenceChecker and generateChecks is still a bit rough around the
edges and needs a bit more refactoring.

See https://github.com/llvm/llvm-project/issues/53590.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119078

Files:
  llvm/include/llvm/Analysis/LoopAccessAnalysis.h
  llvm/include/llvm/Transforms/Utils/LoopUtils.h
  llvm/lib/Analysis/LoopAccessAnalysis.cpp
  llvm/lib/Transforms/Utils/LoopUtils.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/ARM/mve-qabs.ll
  llvm/test/Transforms/LoopVectorize/multiple-strides-vectorization.ll
  llvm/test/Transforms/LoopVectorize/no_outside_user.ll
  llvm/test/Transforms/LoopVectorize/runtime-check.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119078.406243.patch
Type: text/x-patch
Size: 26464 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220206/b202092e/attachment-0001.bin>


More information about the llvm-commits mailing list