# HG changeset patch # User Frits van Bommel # Date 1239875923 -7200 # Node ID a0844cc67840bcab5fa8c723e9570e09eadbd70e # Parent 7977096f0e49c7fb8f21317457c4505267aa0158 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) diff -r 7977096f0e49 -r a0844cc67840 gen/optimizer.cpp --- 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