llvm-6502/lib/Transforms/IPO
Hal Finkel bebe48dbfe Add a loop rerolling pass
This adds a loop rerolling pass: the opposite of (partial) loop unrolling. The
transformation aims to take loops like this:

for (int i = 0; i < 3200; i += 5) {
  a[i]     += alpha * b[i];
  a[i + 1] += alpha * b[i + 1];
  a[i + 2] += alpha * b[i + 2];
  a[i + 3] += alpha * b[i + 3];
  a[i + 4] += alpha * b[i + 4];
}

and turn them into this:

for (int i = 0; i < 3200; ++i) {
  a[i] += alpha * b[i];
}

and loops like this:

for (int i = 0; i < 500; ++i) {
  x[3*i] = foo(0);
  x[3*i+1] = foo(0);
  x[3*i+2] = foo(0);
}

and turn them into this:

for (int i = 0; i < 1500; ++i) {
  x[i] = foo(0);
}

There are two motivations for this transformation:

  1. Code-size reduction (especially relevant, obviously, when compiling for
code size).

  2. Providing greater choice to the loop vectorizer (and generic unroller) to
choose the unrolling factor (and a better ability to vectorize). The loop
vectorizer can take vector lengths and register pressure into account when
choosing an unrolling factor, for example, and a pre-unrolled loop limits that
choice. This is especially problematic if the manual unrolling was optimized
for a machine different from the current target.

The current implementation is limited to single basic-block loops only. The
rerolling recognition should work regardless of how the loop iterations are
intermixed within the loop body (subject to dependency and side-effect
constraints), but the significant restriction is that the order of the
instructions in each iteration must be identical. This seems sufficient to
capture all current use cases.

This pass is not currently enabled by default at any optimization level.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194939 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-16 23:59:05 +00:00
..
ArgumentPromotion.cpp ArgumentPromotion: correctly transfer TBAA tags and alignments. 2013-11-15 20:41:15 +00:00
BarrierNoopPass.cpp
CMakeLists.txt
ConstantMerge.cpp Corruptly merge constants with explicit and implicit alignments. 2013-11-12 20:21:43 +00:00
DeadArgumentElimination.cpp Fix spelling, grammar, and match naming convention for test files. 2013-10-21 23:14:06 +00:00
ExtractGV.cpp
FunctionAttrs.cpp Merge CallGraph and BasicCallGraph. 2013-10-31 03:03:55 +00:00
GlobalDCE.cpp Implement function prefix data as an IR feature. 2013-09-16 01:08:15 +00:00
GlobalOpt.cpp Remove dead code 2013-11-04 21:44:01 +00:00
InlineAlways.cpp Merge CallGraph and BasicCallGraph. 2013-10-31 03:03:55 +00:00
Inliner.cpp Fix comparisons of alloca alignment in inliner merging 2013-07-17 14:32:41 +00:00
InlineSimple.cpp Spell "Actual" correctly 2013-11-03 11:09:39 +00:00
Internalize.cpp Use LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN instead of the "dso list". 2013-10-31 20:51:58 +00:00
IPConstantPropagation.cpp
IPO.cpp Use LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN instead of the "dso list". 2013-10-31 20:51:58 +00:00
LLVMBuild.txt
LoopExtractor.cpp
Makefile
MergeFunctions.cpp Teach MergeFunctions about address spaces 2013-11-10 01:44:37 +00:00
PartialInlining.cpp
PassManagerBuilder.cpp Add a loop rerolling pass 2013-11-16 23:59:05 +00:00
PruneEH.cpp Merge CallGraph and BasicCallGraph. 2013-10-31 03:03:55 +00:00
StripDeadPrototypes.cpp
StripSymbols.cpp Fixed typo. 2013-08-27 04:43:03 +00:00