[PATCH] D82927: Intergerate Loop Peeling into Loop Fusion

Sidharth Baveja via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 30 19:00:15 PDT 2020


sidbav created this revision.
sidbav added reviewers: kbarton, Meinersbur, bkramer, Whitney, skatkov, ashlykov, fhahn.
sidbav added a project: LLVM.
Herald added subscribers: llvm-commits, zzheng, hiraditya, mgorny.

This patch adds the ability to peel off iterations of the first loop in loop fusion. This can allow for both loops to have the same trip count, making it legal for them to be fused together. Additionally this patch adds in some changes to Loop Peeling in order to generalize it since it is no longer just being used by Loop Unrolling.

Here is a simple scenario peeling can be used in loop fusion:

  for (i = 0; i < 10; ++i)
    a[i] = a[i] + 3;
  for (j = 1; j < 10; ++j)
    b[j] = b[j] + 5;

Here is we can make use of peeling, and then fuse the two loops together. We can peel off the 0th iteration of the loop i, and then combine loop i and j for i = 1 to 10.

  a[0] = a[0] +3;
  for (i = 1; i < 10; ++i) {
    a[i] = a[i] + 3;
    b[i] = b[i] + 5;
  }

Currently peeling with loop fusion is only supported for loops with constant trip counts and a single exit point. Both unguarded and guarded loops are supported.

This patch is a followup to D80580 <https://reviews.llvm.org/D80580>. In that patch I separate the peeling specific parameters in the UnrollingPreferences struct and form a new struct called PeelingPreferences.

The diff of this patch was created assuming that D80580 <https://reviews.llvm.org/D80580> is merged.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82927

Files:
  llvm/include/llvm/Transforms/Utils/LoopPeel.h
  llvm/include/llvm/Transforms/Utils/UnrollLoop.h
  llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp
  llvm/lib/Transforms/Scalar/LoopFuse.cpp
  llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp
  llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
  llvm/lib/Transforms/Utils/CMakeLists.txt
  llvm/lib/Transforms/Utils/LoopPeel.cpp
  llvm/lib/Transforms/Utils/LoopUnroll.cpp
  llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
  llvm/test/Transforms/LoopFusion/guarded_peel.ll
  llvm/test/Transforms/LoopFusion/guarded_unsafeblock_peel.ll
  llvm/test/Transforms/LoopFusion/nonadjacent_peel.ll
  llvm/test/Transforms/LoopFusion/peel.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82927.274664.patch
Type: text/x-patch
Size: 56946 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200701/e3a76734/attachment.bin>


More information about the llvm-commits mailing list