[PATCH] D27734: [LoopUnroll] Enable PGO-based loop peeling by default

Michael Kuperstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 13 14:34:21 PST 2016

mkuper created this revision.
mkuper added reviewers: anemet, danielcdh, haicheng.
mkuper added subscribers: llvm-commits, davidxl, mzolotukhin.

This enables loop peeling by default when profile information is available.

Performance on SPEC looks flat, modulo noise.  I am, however, seeing improvements on internal benchmarks, for instrumentation-based PGO.
The previous improvement in SPEC povray disappeared. Either it was a fluke after all, or it was "swallowed" by r287186 (that is, the important thing for povray was disabling runtime unrolling, not enabling peeling).

Two caveats:

1. The mean size increase for SPEC is 1.4%, the total .text size increase is ~0.5%. Most size increases are very modest, and we even have some size decreases (I guess due to interaction with inlining.), but there are a couple of outliers - bzip2 grows by ~10.5%, and sphinx3 by ~4.5%. For the set of internal benchmarks, the size impact is much smaller.
2. This may cause regressions if the profile information is very inaccurate (no surprise). The unfortunate part is that this currently happens for sampling PGO, because we can get weight(preheader) = weight(header), causing us to peel one iteration. The case I'm seeing should be fixed once https://reviews.llvm.org/D26256 lands, but there may be more.

Anyone interested in testing this for their PGO workloads?



Index: test/Transforms/LoopUnroll/peel-loop-pgo.ll
--- test/Transforms/LoopUnroll/peel-loop-pgo.ll
+++ test/Transforms/LoopUnroll/peel-loop-pgo.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -S -debug-only=loop-unroll -loop-unroll -unroll-allow-peeling 2>&1 | FileCheck %s
+; RUN: opt < %s -S -debug-only=loop-unroll -loop-unroll 2>&1 | FileCheck %s
 ; REQUIRES: asserts
 ; Make sure we use the profile information correctly to peel-off 3 iterations
Index: lib/Transforms/Scalar/LoopUnrollPass.cpp
--- lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -108,7 +108,7 @@
              "aggressively unrolled."));
 static cl::opt<bool>
-    UnrollAllowPeeling("unroll-allow-peeling", cl::Hidden,
+    UnrollAllowPeeling("unroll-allow-peeling", cl::init(true), cl::Hidden,
                        cl::desc("Allows loops to be peeled when the dynamic "
                                 "trip count is known to be low."));

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27734.81299.patch
Type: text/x-patch
Size: 1087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161213/6976cbba/attachment.bin>

More information about the llvm-commits mailing list