OSDN Git Service

[UnrollAndJam] Add a new Unroll and Jam pass
authorDavid Green <david.green@arm.com>
Sun, 27 May 2018 12:11:21 +0000 (12:11 +0000)
committerDavid Green <david.green@arm.com>
Sun, 27 May 2018 12:11:21 +0000 (12:11 +0000)
commit3dde46793ca6b6fa57481e41fdeb99d22a70af39
tree61dde3d1d4dcc7cf56acdb779d58cf63d9e629e8
parent717390cf59dc6083982409fe5af550c47c379751
[UnrollAndJam] Add a new Unroll and Jam pass

This is a simple implementation of the unroll-and-jam classical loop
optimisation.

The basic idea is that we take an outer loop of the form:

for i..
  ForeBlocks(i)
  for j..
    SubLoopBlocks(i, j)
  AftBlocks(i)

Instead of doing normal inner or outer unrolling, we unroll as follows:

for i... i+=2
  ForeBlocks(i)
  ForeBlocks(i+1)
  for j..
    SubLoopBlocks(i, j)
    SubLoopBlocks(i+1, j)
  AftBlocks(i)
  AftBlocks(i+1)
Remainder

So we have unrolled the outer loop, then jammed the two inner loops into
one. This can lead to a simpler inner loop if memory accesses can be shared
between the now-jammed loops.

To do this we have to prove that this is all safe, both for the memory
accesses (using dependence analysis) and that ForeBlocks(i+1) can move before
AftBlocks(i) and SubLoopBlocks(i, j).

Differential Revision: https://reviews.llvm.org/D41953

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333358 91177308-0d34-0410-b5e6-96231b3b80d8
23 files changed:
include/llvm-c/Transforms/Scalar.h
include/llvm/Analysis/TargetTransformInfo.h
include/llvm/InitializePasses.h
include/llvm/LinkAllPasses.h
include/llvm/Transforms/Scalar.h
include/llvm/Transforms/Scalar/LoopUnrollAndJamPass.h [new file with mode: 0644]
include/llvm/Transforms/Utils/UnrollLoop.h
lib/Passes/PassBuilder.cpp
lib/Passes/PassRegistry.def
lib/Target/ARM/ARMTargetTransformInfo.cpp
lib/Transforms/IPO/PassManagerBuilder.cpp
lib/Transforms/Scalar/CMakeLists.txt
lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp [new file with mode: 0644]
lib/Transforms/Scalar/LoopUnrollPass.cpp
lib/Transforms/Scalar/Scalar.cpp
lib/Transforms/Utils/CMakeLists.txt
lib/Transforms/Utils/LoopUnroll.cpp
lib/Transforms/Utils/LoopUnrollAndJam.cpp [new file with mode: 0644]
test/Transforms/LoopUnrollAndJam/dependencies.ll [new file with mode: 0644]
test/Transforms/LoopUnrollAndJam/disable.ll [new file with mode: 0644]
test/Transforms/LoopUnrollAndJam/pragma.ll [new file with mode: 0644]
test/Transforms/LoopUnrollAndJam/unprofitable.ll [new file with mode: 0644]
test/Transforms/LoopUnrollAndJam/unroll-and-jam.ll [new file with mode: 0644]