Add basic loop fusion pass.
authorKit Barton <kbarton@ca.ibm.com>
Wed, 17 Apr 2019 18:53:27 +0000 (18:53 +0000)
committerKit Barton <kbarton@ca.ibm.com>
Wed, 17 Apr 2019 18:53:27 +0000 (18:53 +0000)
commit3cdf87940f05a66b8051ce3803c7cfbc91c108ce
tree377e6db9cee027c4a3f4d5396a55ab91362705fe
parenta96efb654e91065697861bdb4541a793b25ecc6b
Add basic loop fusion pass.

This patch adds a basic loop fusion pass. It will fuse loops that conform to the
following 4 conditions:
  1. Adjacent (no code between them)
  2. Control flow equivalent (if one loop executes, the other loop executes)
  3. Identical bounds (both loops iterate the same number of iterations)
  4. No negative distance dependencies between the loop bodies.

The pass does not make any changes to the IR to create opportunities for fusion.
Instead, it checks if the necessary conditions are met and if so it fuses two
loops together.

The pass has not been added to the pass pipeline yet, and thus is not enabled by
default. It can be run stand alone using the -loop-fusion option.

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

llvm-svn: 358607
13 files changed:
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/Transforms/Scalar.h
llvm/include/llvm/Transforms/Scalar/LoopFuse.h [new file with mode: 0644]
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/Scalar/CMakeLists.txt
llvm/lib/Transforms/Scalar/LoopFuse.cpp [new file with mode: 0644]
llvm/lib/Transforms/Scalar/Scalar.cpp
llvm/test/Transforms/LoopFusion/cannot_fuse.ll [new file with mode: 0644]
llvm/test/Transforms/LoopFusion/four_loops.ll [new file with mode: 0644]
llvm/test/Transforms/LoopFusion/inner_loops.ll [new file with mode: 0644]
llvm/test/Transforms/LoopFusion/loop_nest.ll [new file with mode: 0644]
llvm/test/Transforms/LoopFusion/simple.ll [new file with mode: 0644]