]> granicus.if.org Git - clang/commit
Add -freroll-loops to enable loop rerolling
authorHal Finkel <hfinkel@anl.gov>
Sun, 17 Nov 2013 16:03:29 +0000 (16:03 +0000)
committerHal Finkel <hfinkel@anl.gov>
Sun, 17 Nov 2013 16:03:29 +0000 (16:03 +0000)
commitce5b5f13a6c90904040b29b9eb765bb7cd736f0b
treed3b7a7ffc356593bbc52a488bf2c2269ebe3b681
parent8c927fca2a31d1dda461cdf3be6aab3fa25c70b4
Add -freroll-loops to enable loop rerolling

This adds -freroll-loops (and -fno-reroll-loops in the usual way) to enable
loop rerolling as part of the optimization pass manager. This transformation
can enable vectorization, reduce code size (or both).

Briefly, loop rerolling can transform a loop 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];
}

into this:

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

Loop rerolling is currently disabled by default at all optimization levels.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194967 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Driver/Options.td
include/clang/Frontend/CodeGenOptions.def
lib/CodeGen/BackendUtil.cpp
lib/Driver/Tools.cpp
lib/Frontend/CompilerInvocation.cpp
test/Driver/clang_f_opts.c