Skip to content

Commit 30b0c92

Browse files
committed
Optimizer: remove the ArrayElementPropagation optimization
Propagating array element values is done by load-simplification and redundant-load-elimination. So ArrayElementPropagation is not needed anymore. ArrayElementPropagation also replaced `Array.append(contentsOf:)` with individual `Array.append` calls. This optimization is removed, because the benefit is questionably, anyway. In most cases it resulted in a code size increase.
1 parent 88c2905 commit 30b0c92

File tree

10 files changed

+64
-1403
lines changed

10 files changed

+64
-1403
lines changed

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ IRGEN_PASS(AllocStackHoisting, "alloc-stack-hoisting",
120120
"SIL alloc_stack Hoisting")
121121
PASS(ArrayCountPropagation, "array-count-propagation",
122122
"Array Count Propagation")
123-
PASS(ArrayElementPropagation, "array-element-propagation",
124-
"Array Element Propagation")
125123
SWIFT_FUNCTION_PASS(AssumeSingleThreaded, "sil-assume-single-threaded",
126124
"Assume Single-Threaded Environment")
127125
SWIFT_MODULE_PASS(AsyncDemotion, "async-demotion",

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ void addHighLevelLoopOptPasses(SILPassPipelinePlan &P) {
403403
P.addSimplifyCFG();
404404
P.addPerformanceConstantPropagation();
405405
P.addSimplifyCFG();
406-
P.addArrayElementPropagation();
407406
// End of unrolling passes.
408407
P.addABCOpt();
409408
// Cleanup.
@@ -467,14 +466,10 @@ void addFunctionPasses(SILPassPipelinePlan &P,
467466

468467
addSimplifyCFGSILCombinePasses(P);
469468

470-
P.addArrayElementPropagation();
471-
472469
// Perform a round of loop/array optimization in the mid-level pipeline after
473470
// potentially inlining semantic calls, e.g. Array append. The high level
474471
// pipeline only optimizes semantic calls *after* inlining (see
475-
// addHighLevelLoopOptPasses). For example, the high-level pipeline may
476-
// perform ArrayElementPropagation and after inlining a level of semantic
477-
// calls, the mid-level pipeline may handle uniqueness hoisting. Do this as
472+
// addHighLevelLoopOptPasses). Do this as
478473
// late as possible before inlining because it must run between runs of the
479474
// inliner when the pipeline restarts.
480475
if (OpLevel == OptimizationLevelKind::MidLevel) {

0 commit comments

Comments
 (0)