develooper Front page | perl.perl5.porters | Postings from October 2017

Adding a new optimisation phase

Thread Next
Dave Mitchell
October 25, 2017 12:17
Adding a new optimisation phase
Message ID:
The branch I've just pushed, smoke-me/davem/mconcat, for the new
OP_MULTICONAT optimisation, also contains a new function in op.c,
Perl_optimize_optree(), which represents a new additional optimisation

It does a top-down scan of a complete optree, just before running the
peephole optimiser.

i.e. previously the order was

    ck_foo()          - called on each foo subtree as it's created;
    peep()            - examine a complete optree in op_next execution
    finalize_optree() - scan complete optree in top-down order, to
                        do any final fixups and optimisations.

The new order is

    optimize_optree() - scan complete optree in top-down order, to
                        do some optimisations;

This has the benefits that:
* unlike ck_foo(), it can see the complete optree;
* unlike peep(), it scans the optree in top-down order;
* unlike finalize_optree(), it sees the optree before it's been mangled
  to death by peep(); and any nodes it nulls out will still be
  subsequently be removed from the execution chain by peep().

It appears to have minimal affect on overall compilation time.

It's not that I'm afraid to die, I just don't want to be there when it
    -- Woody Allen

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About