Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bad optimisations: (Was: Test version zsh-3.1.6-test-1)



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