[PATCH] D110972: [DA] Handle mismatching loop levels by updating the numbering scheme

Bardia Mahjour via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 1 13:54:12 PDT 2021


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

To represent various loop levels within a nest, DA implements a special numbering scheme (see comment atop `establishNestingLevels`). The goal of this numbering scheme appears to be representing each unique loop distinctively by using as little memory as possible. This numbering scheme is simple when the source and destination of the dependence are in the same loop. In such cases the level is simply the depth of the loop in which src and dst reside. When the src and dst are not in the same loop, we could run into the following situation exposed by https://reviews.llvm.org/D71539.

Suppose we have the following loop structure and memory access:

  1: L1
  2:    L2
  3:    A[s1] 
  4:    L3
  5:        A[s2]

Further assume that the subscript of the first access (ie `s1`) is an LCSSA phi with a single incoming value from L2. With the change in D71539 <https://reviews.llvm.org/D71539>, the SCEV expression for `s1` (queried at the scope of L1 <https://reviews.llvm.org/L1> where the access on line 3 occurs) will be an AddRec whose loop is L2.

Since the access `A[s1]` occurs at a loop depth of 1, but its subscript references a loop at depth 2, the current numbering scheme gets confused and assigns the same level value to both `s1` and `s2`, which further causes `classifyPair` to incorrectly classify the subscript pair.

This patch proposes a slight change to the numbering scheme using the subscript SCEVs to treat the memory access instructions in such cases, as if they appeared inside the AddRec loop of the inner-most subscript.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110972

Files:
  llvm/include/llvm/Analysis/DependenceAnalysis.h
  llvm/lib/Analysis/DependenceAnalysis.cpp
  llvm/test/Analysis/DependenceAnalysis/MismatchingNestLevels.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110972.376622.patch
Type: text/x-patch
Size: 9508 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211001/fe5dbbc6/attachment.bin>


More information about the llvm-commits mailing list