]> granicus.if.org Git - llvm/commit
Title: Loop Cache Analysis
authorWhitney Tsang <whitney.uwaterloo@gmail.com>
Fri, 9 Aug 2019 13:56:29 +0000 (13:56 +0000)
committerWhitney Tsang <whitney.uwaterloo@gmail.com>
Fri, 9 Aug 2019 13:56:29 +0000 (13:56 +0000)
commitb2f93fd3ba882347489676d1b35abdc9e07e8ac4
treed7774352ed96d4c59cf0b98904ccdecf14f06df0
parent246185486040c9c54db2db6f8efcc54bb9ce1267
Title: Loop Cache Analysis
Summary: Implement a new analysis to estimate the number of cache lines
required by a loop nest.
The analysis is largely based on the following paper:

Compiler Optimizations for Improving Data Locality
By: Steve Carr, Katherine S. McKinley, Chau-Wen Tseng
http://www.cs.utexas.edu/users/mckinley/papers/asplos-1994.pdf
The analysis considers temporal reuse (accesses to the same memory
location) and spatial reuse (accesses to memory locations within a cache
line). For simplicity the analysis considers memory accesses in the
innermost loop in a loop nest, and thus determines the number of cache
lines used when the loop L in loop nest LN is placed in the innermost
position.

The result of the analysis can be used to drive several transformations.
As an example, loop interchange could use it determine which loops in a
perfect loop nest should be interchanged to maximize cache reuse.
Similarly, loop distribution could be enhanced to take into
consideration cache reuse between arrays when distributing a loop to
eliminate vectorization inhibiting dependencies.

The general approach taken to estimate the number of cache lines used by
the memory references in the inner loop of a loop nest is:

Partition memory references that exhibit temporal or spatial reuse into
reference groups.
For each loop L in the a loop nest LN: a. Compute the cost of the
reference group b. Compute the 'cache cost' of the loop nest by summing
up the reference groups costs
For further details of the algorithm please refer to the paper.
Authored By: etiotto
Reviewers: hfinkel, Meinersbur, jdoerfert, kbarton, bmahjour, anemet,
fhahn
Reviewed By: Meinersbur
Subscribers: reames, nemanjai, MaskRay, wuzish, Hahnfeld, xusx595,
venkataramanan.kumar.llvm, greened, dmgreen, steleman, fhahn, xblvaOO,
Whitney, mgorny, hiraditya, mgrang, jsji, llvm-commits
Tag: LLVM
Differential Revision: https://reviews.llvm.org/D63459

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368439 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/LoopCacheAnalysis.h [new file with mode: 0644]
lib/Analysis/CMakeLists.txt
lib/Analysis/LoopCacheAnalysis.cpp [new file with mode: 0644]
lib/Passes/PassBuilder.cpp
lib/Passes/PassRegistry.def
test/Analysis/LoopCacheAnalysis/PowerPC/lit.local.cfg [new file with mode: 0644]
test/Analysis/LoopCacheAnalysis/PowerPC/loads-store.ll [new file with mode: 0644]
test/Analysis/LoopCacheAnalysis/PowerPC/matmul.ll [new file with mode: 0644]
test/Analysis/LoopCacheAnalysis/PowerPC/matvecmul.ll [new file with mode: 0644]
test/Analysis/LoopCacheAnalysis/PowerPC/single-store.ll [new file with mode: 0644]
test/Analysis/LoopCacheAnalysis/PowerPC/stencil.ll [new file with mode: 0644]