[PATCH] D18158: Adding ability to unroll loops using epilogue remainder.

Evgeny Stupachenko via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 14 14:17:05 PDT 2016


evstupac created this revision.
evstupac added reviewers: sanjoy, aizatsky, hfinkel, chandlerc, mzolotukhin.
evstupac added a subscriber: llvm-commits.
evstupac set the repository for this revision to rL LLVM.
Herald added a subscriber: sanjoy.

The patch adds an ability to unroll loops using epilogue remainder and makes it default (instead of current prologue),
The epilogue remainder is better as it do not produce additional non-constant phi nodes.
for(i = 0; i < n; i++)
  ...
For now loop unrolling looks like:
PROLOG:
  ip = phi [0, ip.next]
  ...
  ip.next = ip + 1
  cmp ip, n&7
jne PROLOG
i0 = phi [0, ip.next]
LOOP (unrolling on 8):
  i = phi [**i0**, i.next]
  i.next = i + 1
  cmp i, n
jne LOOP

In the LOOP (this is supposed to be unrolled) we have i = phi [**i0**, i.next].
Basically, that means that we don't know where we start now, however before unrolling we knew the start position is 0.
Assuming unrolled part of the loop is hotter than remainder (prologue currently), it is better to move this induction variable with unknown start to remainder code (which is done by epilogue technique).


Repository:
  rL LLVM

http://reviews.llvm.org/D18158

Files:
  include/llvm/Transforms/Utils/UnrollLoop.h
  lib/Transforms/Utils/LoopUnroll.cpp
  lib/Transforms/Utils/LoopUnrollRuntime.cpp
  test/Transforms/LoopUnroll/AArch64/runtime-loop.ll
  test/Transforms/LoopUnroll/PowerPC/a2-unrolling.ll
  test/Transforms/LoopUnroll/X86/mmx.ll
  test/Transforms/LoopUnroll/high-cost-trip-count-computation.ll
  test/Transforms/LoopUnroll/runtime-loop.ll
  test/Transforms/LoopUnroll/runtime-loop1.ll
  test/Transforms/LoopUnroll/runtime-loop2.ll
  test/Transforms/LoopUnroll/runtime-loop4.ll
  test/Transforms/LoopUnroll/runtime-loop5.ll
  test/Transforms/LoopUnroll/tripcount-overflow.ll
  test/Transforms/LoopUnroll/unroll-cleanup.ll
  test/Transforms/LoopUnroll/unroll-pragmas.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18158.50633.patch
Type: text/x-patch
Size: 47123 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160314/19d8c8a2/attachment.bin>


More information about the llvm-commits mailing list