[PATCH] D72178: [DA] Delinearization of fixed-size multi-dimensional arrays

Bardia Mahjour via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 3 13:20:40 PST 2020


bmahjour created this revision.
bmahjour added reviewers: sebpop, fhahn, Meinersbur, dmgreen, hfinkel, grosser, etiotto.
bmahjour added projects: LLVM, Polly.
Herald added a reviewer: bollu.
Herald added subscribers: llvm-commits, wuzish, hiraditya.

Currently the dependence analysis in LLVM is unable to compute accurate dependence vectors for multi-dimensional fixed size arrays. For example:

  #define N 1024
  #define M 2048
  void foo(int a[N][M]) {                                                                                                                                                                                                                                                                                                                                                                                                               
    for (long i = 0; i < N-1; ++i)                                                                                                                                                                                      
      for (long j = 2; j < M; ++j)                                                                                                                                                                                      
        a[i][j] = a[i+1][j-2];

gives the following output for the dependence between the load of `a[i+1][j-2]` and the store into `a[i][j]`:

  da analyze - anti [< >]!

While the direction vectors are correct, no dependence distances are computed, as we expect:

  da analyze - anti [1 -2]!

This is mainly because the delinearization algorithm in scalar evolution relies on parametric terms to be present in the access functions. In the case of fixed size arrays such parametric terms are not present, but we can use the indexes from GEP instructions to recover the subscripts for each dimension of the arrays.

It appears that https://reviews.llvm.org/D35430 removed the capability to look at GEP instructions early in 2018. The justification for that change appears to be related to the concern over subscripts overlapping into next array dimensions in languages like C/C++. Please note that https://reviews.llvm.org/D62610 added a debug option to address this concern.

Removing support for fixed-size array delinearization resulted in over-pissimization of DependenceAnalysis and reduction of test coverage for both DA and LoopInterchange.

In this patch I add support for fixed-size array delinearization back under the option introduced in D62610 <https://reviews.llvm.org/D62610> (with a renaming of the option). I've also noticed that polly tries to recover fixed-size array subscripts for dependence testing, so I've refactored the polly code and moved it to scalar-evolution to make it reuseable by both polly and DA.

Quite a few DA and loop interchange test cases improve as a result of this change, and it makes writing tests for new and existing transformations easier.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72178

Files:
  llvm/include/llvm/Analysis/DependenceAnalysis.h
  llvm/include/llvm/Analysis/ScalarEvolution.h
  llvm/lib/Analysis/DependenceAnalysis.cpp
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/test/Analysis/DependenceAnalysis/Coupled.ll
  llvm/test/Analysis/DependenceAnalysis/FixedSizeArray.ll
  llvm/test/Analysis/DependenceAnalysis/Invariant.ll
  llvm/test/Analysis/DependenceAnalysis/NonCanonicalizedSubscript.ll
  llvm/test/Analysis/DependenceAnalysis/Preliminary.ll
  llvm/test/Analysis/DependenceAnalysis/Propagating.ll
  llvm/test/Analysis/DependenceAnalysis/Separability.ll
  llvm/test/Analysis/DependenceAnalysis/SimpleSIVNoValidityCheck.ll
  llvm/test/Transforms/LoopInterchange/currentLimitation.ll
  llvm/test/Transforms/LoopInterchange/loop-interchange-optimization-remarks.ll
  llvm/test/Transforms/LoopInterchange/profitability.ll
  polly/include/polly/Support/ScopHelper.h
  polly/lib/Analysis/ScopBuilder.cpp
  polly/lib/Support/ScopHelper.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72178.236114.patch
Type: text/x-patch
Size: 36237 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200103/8a9a5748/attachment-0001.bin>


More information about the llvm-commits mailing list