Mercurial > projects > ldc
changeset 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 | 7977096f0e49 |
children | e945d2a0999e |
files | gen/optimizer.cpp |
diffstat | 1 files changed, 19 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/optimizer.cpp Wed Apr 15 21:37:01 2009 +0200 +++ b/gen/optimizer.cpp Thu Apr 16 11:58:43 2009 +0200 @@ -65,7 +65,10 @@ pm.add(createGlobalDCEPass()); pm.add(createRaiseAllocationsPass()); pm.add(createCFGSimplificationPass()); - pm.add(createPromoteMemoryToRegisterPass()); + if (optimizeLevel == 1) + pm.add(createPromoteMemoryToRegisterPass()); + else + pm.add(createScalarReplAggregatesPass()); pm.add(createGlobalOptimizerPass()); pm.add(createGlobalDCEPass()); } @@ -83,6 +86,21 @@ // -inline if (doInline()) { pm.add(createFunctionInliningPass()); + + if (optimizeLevel >= 2) { + // Run some optimizations to clean up after inlining. + pm.add(createInstructionCombiningPass()); + pm.add(createScalarReplAggregatesPass()); + + // Inline again, to catch things like foreach delegates + // passed inlined opApply's where the function wasn't + // known during the first inliner pass. + pm.add(createFunctionInliningPass()); + + // Run clean-up again. + pm.add(createInstructionCombiningPass()); + pm.add(createScalarReplAggregatesPass()); + } } // -O3