develooper Front page | perl.perl5.porters | Postings from August 2010

Re: [perl #76438] peephole optimiser could prune more dead code

Thread Previous | Thread Next
Aristotle Pagaltzis
August 6, 2010 07:10
Re: [perl #76438] peephole optimiser could prune more dead code
Message ID:
* Eric Brine <> [2010-07-12 06:55]:
> On Sun, Jul 11, 2010 at 10:22 PM, David Golden <> wrote:
> > I'm suggesting that we disclaim any implicit guarantee that the
> > compiler won't optimize away expressions that have side effects when
> > evaluated.
> >
> Without that guarantee,
> my $x = f()
>    or DEBUG && warn(...);
> return $x;
> would be buggy. Dunno if that matters


As far as I can tell, the compiler would statically determine
that it can optimise the `DEBUG && warn` part down to `!1` when
`DEBUG` is false. This seems correct to me.

It would also statically determine that an `or !1` clause in that
statement does nothing, and so fold it away altogether.

That would leave the code looking like

    my $x = f();
    return $x;

when `DEBUG` is false.

Which seems 100% on the mark to me.

Am I missing something in your objection?

Aristotle Pagaltzis // <>

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