Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bad optimisations: (Was: Test version zsh-3.1.6-test-1)
- X-seq: zsh-workers 7169
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: Bad optimisations: (Was: Test version zsh-3.1.6-test-1)
- Date: Fri, 16 Jul 1999 11:12:52 +0200 (MET DST)
- In-reply-to: Sven Wischnowsky's message of Fri, 16 Jul 1999 10:56:36 +0200 (MET DST)
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
I wrote:
> mason@xxxxxxxxxxxxxxx wrote:
>
> > Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx> typed:
> > :Geoff Wing wrote:
> > :> What about just expanding it slightly (with appropriate comments of course)
> > :> instead of duplicating it.
> > :> e.g.
> > :> if (*args && **args == '?')
> > :> args++;
> > :> /* default result parameter */
> > :> if (*args)
> > :> reply = *args++;
> > :> else
> > :> reply = ops['A'] ? "reply" : "REPLY";
> > :Note this isn't intended as an optimisation (of course), but to work
> > :around a bug in gcc-2.8.1 under DU.
> >
> > I thought it may be a gcc optimisation bug. i.e. Does it appear at -O0 or
> > -01 or -O2? All of them?
>
> Yes, it is. The problem is in the first two lines of the code
> above. If there is only the `args++' in the `then'-branch, `args'
> contains a random value after the `if'. This happens with all
> optimisation levels, so I guess it's a register allocation problem in
> the backend.
Playing some more: both
firstarg = (*args && **args == '?' ? *args++ : *args);
and
if (*args && **args == '?')
firstarg = *args++;
else
firstarg = *args;
work around the bug, too. Should I send a patch for one of these? They
probably keep the code better readable (although they don't look much
less silly).
Bye
Sven
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author