Branch: refs/heads/davem/cond_null
  Home:   https://github.com/Perl/perl5
  Commit: bfd7e5c67cc6c6fc0eff5df51a326f6a68d67930
      
https://github.com/Perl/perl5/commit/bfd7e5c67cc6c6fc0eff5df51a326f6a68d67930
  Author: David Mitchell <[email protected]>
  Date:   2026-02-13 (Fri, 13 Feb 2026)

  Changed paths:
    M peep.c

  Log Message:
  -----------
  rpeep(): refactor: simplify LOGOP handling

(should be no functional changes)

In the main loop of the peephole optimiser, add the label
'generic_logop' in preparation for further refactroring/fixing in the
next few commits.

Use it now to make the 'case OP_GREPWHILE' go directly to the generic
processing rather than falling through to the OP_COND_EXPR branch. In
turn, that branch no longer has to check that its actually an
OP_COND_EXPR.


  Commit: be7e97ed45337f6f3560d28289d11497c14547bc
      
https://github.com/Perl/perl5/commit/be7e97ed45337f6f3560d28289d11497c14547bc
  Author: David Mitchell <[email protected]>
  Date:   2026-02-13 (Fri, 13 Feb 2026)

  Changed paths:
    M peep.c
    M t/perf/benchmarks

  Log Message:
  -----------
  fix performance regression in empty ? :

Some recent commits optimised away the stub op in expressions such as

    @a = $c ? () : @b;

Unfortunately at the same time as eliminating the stub op, the change
made rpeep() skip following op_other to remove any OP_NULLs from that
branch. This commit restores the old behaviour and adds some benchmarks
for (?:)

In particular: before this commit, the code above generated:

    4  <#> gvsv[*c] s
    5  <|> cond_expr(other->6) lK/1
    6      <1> null lKP/1
    7      <1> ex-list lK
               goto 8
    d  <#> gv[*b] s
    e  <1> rv2av[t5] lK/1
    8  <0> pushmark s
    ....

and now generates:

    5  <|> cond_expr(other->6) lK/1
    b  <#> gv[*b] s
    c  <1> rv2av[t5] lK/1
    6  <0> pushmark s
    ....

as displayed with Concise,-exec.


  Commit: 3761b673f2e58b77451ea0dfe82c48aadff5d27f
      
https://github.com/Perl/perl5/commit/3761b673f2e58b77451ea0dfe82c48aadff5d27f
  Author: David Mitchell <[email protected]>
  Date:   2026-02-13 (Fri, 13 Feb 2026)

  Changed paths:
    M peep.c
    M t/perf/opcount.t

  Log Message:
  -----------
  optimise codeblocks of any/all functions

The recently-added any/all experimental list functions weren't
having the code in their code block passed through the peephole
optimiser. So for example with

    use feature 'keyword_any';
    @a = any { $x[0] } @b;

the aelem op in the code block wasn't being optimised into an aelemfast.

The fix is trivial - just make sure that the op_other for the
OP_ANYWHILE op is passed to the peephole optimiser. Also add tests.

Do a similar thing for OP_HELEMEXISTSOR; but since this op isn't
generated by Perl code, I haven't added tests for it.


  Commit: e814a5f88dbdce466bad45169d7ea89032482dd3
      
https://github.com/Perl/perl5/commit/e814a5f88dbdce466bad45169d7ea89032482dd3
  Author: David Mitchell <[email protected]>
  Date:   2026-02-13 (Fri, 13 Feb 2026)

  Changed paths:
    M peep.c

  Log Message:
  -----------
  rpeep(): refactor: simplify catch() handling.

OP_ENTERTRYCATCH's op_other points to an OP_CATCH which has an op_other
pointing to the code in the catch {} block. To ensure that this block
gets passed through the peephole optimiser, just add OP_CATCH to the
list of known LOGOPs which have an op_other needing processing, rather
than special-casing OP_ENTERTRYCATCH to peephole op_other->op_other.

This is infinitesimally less efficient, but makes the code easier to
follow, with one less special case.


  Commit: 4816018c251494dc9f110098eb694c4edd129cd9
      
https://github.com/Perl/perl5/commit/4816018c251494dc9f110098eb694c4edd129cd9
  Author: David Mitchell <[email protected]>
  Date:   2026-02-13 (Fri, 13 Feb 2026)

  Changed paths:
    M peep.c

  Log Message:
  -----------
  rpeep(): refactor: tidy op_other handling.

In the branches handling LOGOPs and op_other,

* use an explicit 'goto generic_logop' rather than relying on
  /* FALLTHROUGH */;

* make OP_ENTERTRY use 'goto generic_logop' rather than having
  its own DEFER() call;

* move the OP_ENTERTRY and OP_ENTERTRYCATCH cases earlier so that
  they are with the other LOGOPs.

Shouldn't be any functional changes.


  Commit: 21ca6f4ac3e2eef9541a4af4d800c7d6f3d5d420
      
https://github.com/Perl/perl5/commit/21ca6f4ac3e2eef9541a4af4d800c7d6f3d5d420
  Author: David Mitchell <[email protected]>
  Date:   2026-02-13 (Fri, 13 Feb 2026)

  Changed paths:
    M peep.c

  Log Message:
  -----------
  rpeep(): assert that some LOGOPs are done

In general, rpeep() needs to follow the op_other pointer of LOGOPs
to optimise the 'other' branch of logical ops. However, some ops don't
need doing, because their op_other doesn't point to general user code,
but to a fixed op which will have already been processed. For example,
OP_SUBSTCONT->op-other always points to its parent OP_SUBST.

Previously these ops were missing from the rpeep() main loop as nothing
needed doing for them. This commit adds them, both for completeness,
and also adds asserts that their op_other points to something which
doesn't need to be processed.

This commit serves two purposes:

* it makes it clear that the op hasn't just been forgotten (I had to
  examine each missing LOGOP and try to work out why it wasn't in
  rpeep() - future people hopefully won't have to repeat this exercise);

* if any of the asserts fail, it is indication that my understanding of
  that op wasn't complete, and that there may in fact be cases where the
  op_other *should* be followed.


  Commit: e3e070f0ad20fa325021cc17325431ca1c737ade
      
https://github.com/Perl/perl5/commit/e3e070f0ad20fa325021cc17325431ca1c737ade
  Author: David Mitchell <[email protected]>
  Date:   2026-02-13 (Fri, 13 Feb 2026)

  Changed paths:
    M peep.c

  Log Message:
  -----------
  rpeep(): refactor: simplify deleting bare if blks

There's some code in rpeep() structured a bit like:

    case OP_COND_EXPR:
        ...
        if (the true branch is a bare stub op) {
            delete the branch;
        }
        elsif (the true branch is a bare enter/scope and stub branch) {
            delete the branch;
        }

This commit changes/simplifies that code to:

        if (   the true branch is a bare stub op
            || the true branch is a bare enter/scope and stub branch)
        {
            delete the branch;
        }


  Commit: 5ead9a175604e10b88182d9a964e24fe0043a15a
      
https://github.com/Perl/perl5/commit/5ead9a175604e10b88182d9a964e24fe0043a15a
  Author: David Mitchell <[email protected]>
  Date:   2026-02-13 (Fri, 13 Feb 2026)

  Changed paths:
    M peep.c

  Log Message:
  -----------
  rpeep(): remove spurious flag setting on LOGOPs

the main loop in rpeep() does

    o->op_opt = 1

on each op just before it processes it, to indicate that the op has been
processed and peephole-optimised.

For some reason, just the OP_AND/OP_OR/etc ops set it again.
This appears superfluous, and changing it to assert(o->op_opt)
didn't trigger any test suite failures, so this commit removes it
altogether.


  Commit: e903581dedfe64ba7e9a4102819b4fb905e3d567
      
https://github.com/Perl/perl5/commit/e903581dedfe64ba7e9a4102819b4fb905e3d567
  Author: David Mitchell <[email protected]>
  Date:   2026-02-13 (Fri, 13 Feb 2026)

  Changed paths:
    M dump.c

  Log Message:
  -----------
  op_dump(): display OTHER on newish LOGOPs

Some recently-added OPs of class LOGOP weren't having their op_other
field displayed by op_dump().


Compare: https://github.com/Perl/perl5/compare/bfd7e5c67cc6%5E...e903581dedfe

To unsubscribe from these emails, change your notification settings at 
https://github.com/Perl/perl5/settings/notifications

Reply via email to