This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Peephole optimise adjacent pairs of nextstate ops.
authorNicholas Clark <nick@ccl4.org>
Fri, 27 Aug 2010 20:48:55 +0000 (21:48 +0100)
committerNicholas Clark <nick@ccl4.org>
Fri, 27 Aug 2010 20:48:55 +0000 (21:48 +0100)
commitac56e7de46621c6f2e373d11984c0a0fe4839b0b
treebb3bb0453fad0152bd4b0aaf97989c0c21cb192f
parentccfef76d964c8b719db5c7fd06ce897a3eb64c01
Peephole optimise adjacent pairs of nextstate ops.

Previously, in code such as

    use constant DEBUG=>0;

    sub GAK {
        warn if DEBUG;
        print "stuff\n";
    }

the ops for C<warn if DEBUG;> would be folded to a null op (ex-const), but
the nextstate op would remain, resulting in a runtime op dispatch of nextstate,
nextstate, ...

The execution of a sequence of nexstate ops is indistinguishable from just the
last nextstate op, so teach the peephole optimiser to eliminate the first of a
pair of nextstate ops. (Except where the first carries a label, as labels
mustn't be eliminated by the optimiser, and label usage isn't conclusively
known at compile time.)
ext/B/t/optree_samples.t
ext/B/t/optree_specials.t
op.c
t/op/goto.t