Skip to content

Commit c042058

Browse files
committed
Modify the optimization pipeline to better support custom array iterators
This patch is supposed to recover the performance regressions that would be introduced by yet to be merged PR #9145, which introduces custom, more efficient array iterators. The crucial part of this patch is running loop unrolling also during the mid-level optimizations phase, because it may catch more loops with constant trip counts. To make trip counts constant, an additional run of constant propagation is helpful.
1 parent 4a1b3bb commit c042058

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,11 @@ void addSSAPasses(SILPassPipelinePlan &P, OptimizationLevelKind OpLevel) {
269269
P.addCSE();
270270
P.addRedundantLoadElimination();
271271

272-
// Perform retain/release code motion and run the first ARC optimizer.
272+
P.addPerformanceConstantPropagation();
273273
P.addCSE();
274274
P.addDCE();
275275

276+
// Perform retain/release code motion and run the first ARC optimizer.
276277
P.addEarlyCodeMotion();
277278
P.addReleaseHoisting();
278279
P.addARCSequenceOpts();
@@ -333,6 +334,10 @@ static void addMidLevelPassPipeline(SILPassPipelinePlan &P) {
333334
// Specialize partially applied functions with dead arguments as a preparation
334335
// for CapturePropagation.
335336
P.addDeadArgSignatureOpt();
337+
338+
// Run loop unrolling after inlining and constant propagation, because loop
339+
// trip counts may have became constant.
340+
P.addLoopUnroll();
336341
}
337342

338343
static void addClosureSpecializePassPipeline(SILPassPipelinePlan &P) {
@@ -402,6 +407,7 @@ static void addLateLoopOptPassPipeline(SILPassPipelinePlan &P) {
402407

403408
// Remove dead code.
404409
P.addDCE();
410+
P.addSILCombine();
405411
P.addSimplifyCFG();
406412

407413
// Try to hoist all releases, including epilogue releases. This should be

0 commit comments

Comments
 (0)