[PATCH] D55851: Implement basic loop fusion pass

Kit Barton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 18 12:52:42 PST 2018


kbarton created this revision.
kbarton added reviewers: jdoerfert, hfinkel, Meinersbur, nemanjai, greened.
Herald added subscribers: hiraditya, mgorny.

Loop fusion is an optimization/transformation that takes two (or more) loops and
fuses (or joins) them together to create a single loop.

This pass implements Basic Loop Fusion. It will fuse loops that conform to the
following 4 conditions:

1. Adjacent (no code in between the two loops)
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 intention is to initially focus on the safety checks and mechanics of loop
fusion. It makes no changes to the IR to create opportunities for fusion.
Instead, it checks the necessary conditions and if all conditions are met, it
fuses two loops together.

Further information on loop fusion, and techniques to improve the opportunities
for loop fusion can be found at
https://webdocs.cs.ualberta.ca/~amaral/thesis/ChristopherBartonMSc.pdf

This patch intentionally does not add the loop fusion pass into the pass
pipeline. The location of loop fusion in the pass pipeline needs to be discussed
and I would prefer to have that discussion outside of this review.


Repository:
  rL LLVM

https://reviews.llvm.org/D55851

Files:
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/Scalar.h
  llvm/include/llvm/Transforms/Scalar/LoopFuse.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Scalar/CMakeLists.txt
  llvm/lib/Transforms/Scalar/LoopFuse.cpp
  llvm/lib/Transforms/Scalar/Scalar.cpp
  llvm/test/Transforms/LoopFusion/cannot_fuse.ll
  llvm/test/Transforms/LoopFusion/four_loops.ll
  llvm/test/Transforms/LoopFusion/inner_loops.ll
  llvm/test/Transforms/LoopFusion/loop_nest.ll
  llvm/test/Transforms/LoopFusion/simple.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55851.178761.patch
Type: text/x-patch
Size: 89012 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181218/c050dccf/attachment.bin>


More information about the llvm-commits mailing list