From ce0697f4759ce369bd28d31a6ed5813d776663de Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Sun, 17 Nov 2013 16:03:29 +0000 Subject: 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. llvm-svn: 194967 --- clang/lib/CodeGen/BackendUtil.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'clang/lib/CodeGen/BackendUtil.cpp') diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index e159a7ab5dc..90b0f68bd69 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -242,6 +242,7 @@ void EmitAssemblyHelper::CreatePasses(TargetMachine *TM) { PMBuilder.DisableUnitAtATime = !CodeGenOpts.UnitAtATime; PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops; + PMBuilder.RerollLoops = CodeGenOpts.RerollLoops; if (!CodeGenOpts.SampleProfileFile.empty()) PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible, -- cgit v1.2.3