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

Adding a new optimisation phase

Thread Next
From:
Dave Mitchell
Date:
October 25, 2017 12:17
Subject:
Adding a new optimisation phase
Message ID:
20171025121649.GQ3083@iabyn.com
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
phase.

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
                        order;
    finalize_optree() - scan complete optree in top-down order, to
                        do any final fixups and optimisations.

The new order is

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

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
happens.
    -- Woody Allen

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About