Mercurial > projects > ldc
comparison gen/optimizer.cpp @ 1219:a0844cc67840
Tweak some optimizations.
Delegates passed to inlined functions now also stand a chance of being inlined.
This should make opApply as efficient as a regular loop, as long as both opApply
and the foreachbody are eligible for inlining; which is to say most non-virtual
opApply invocations will likely get fully inlined now.
(Note: above requires -O2 -enable-inlining or -O3)
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Thu, 16 Apr 2009 11:58:43 +0200 |
parents | cc1efa23030a |
children | e945d2a0999e |
comparison
equal
deleted
inserted
replaced
1218:7977096f0e49 | 1219:a0844cc67840 |
---|---|
63 { | 63 { |
64 //pm.add(createStripDeadPrototypesPass()); | 64 //pm.add(createStripDeadPrototypesPass()); |
65 pm.add(createGlobalDCEPass()); | 65 pm.add(createGlobalDCEPass()); |
66 pm.add(createRaiseAllocationsPass()); | 66 pm.add(createRaiseAllocationsPass()); |
67 pm.add(createCFGSimplificationPass()); | 67 pm.add(createCFGSimplificationPass()); |
68 pm.add(createPromoteMemoryToRegisterPass()); | 68 if (optimizeLevel == 1) |
69 pm.add(createPromoteMemoryToRegisterPass()); | |
70 else | |
71 pm.add(createScalarReplAggregatesPass()); | |
69 pm.add(createGlobalOptimizerPass()); | 72 pm.add(createGlobalOptimizerPass()); |
70 pm.add(createGlobalDCEPass()); | 73 pm.add(createGlobalDCEPass()); |
71 } | 74 } |
72 | 75 |
73 // -O2 | 76 // -O2 |
81 } | 84 } |
82 | 85 |
83 // -inline | 86 // -inline |
84 if (doInline()) { | 87 if (doInline()) { |
85 pm.add(createFunctionInliningPass()); | 88 pm.add(createFunctionInliningPass()); |
89 | |
90 if (optimizeLevel >= 2) { | |
91 // Run some optimizations to clean up after inlining. | |
92 pm.add(createInstructionCombiningPass()); | |
93 pm.add(createScalarReplAggregatesPass()); | |
94 | |
95 // Inline again, to catch things like foreach delegates | |
96 // passed inlined opApply's where the function wasn't | |
97 // known during the first inliner pass. | |
98 pm.add(createFunctionInliningPass()); | |
99 | |
100 // Run clean-up again. | |
101 pm.add(createInstructionCombiningPass()); | |
102 pm.add(createScalarReplAggregatesPass()); | |
103 } | |
86 } | 104 } |
87 | 105 |
88 // -O3 | 106 // -O3 |
89 if (optimizeLevel >= 3) | 107 if (optimizeLevel >= 3) |
90 { | 108 { |