This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: EGCS Optimization bug on HPUX


Reply-To: ddsinc09@ix.netcom.com


Has this issue ever been addressed or looked at?
I haven't seen followup since
John David Anglin <dave@hiauly1.hia.nrc.ca>
a week ago.  Thanks.


> The following code fragment appears in AutoGen's evalExpr_SHSTR
> routine in src/agExpr.c:
> 
>      *(pz++) = '"';
>      for (;;) {
>          switch (*(pz++) = *(pzDta++)) {
>          case NUL:
>              goto loopDone2;
> 
>          case '"':
>          case '\\':
>              pz[-1]  = '\\';
>              *(pz++) = pzDta[-1];
>          }
>      } loopDone2:;
>      pz[-1] = '"';
>      *pz    = NUL;
> 
> AutoGen is available from:
> 
>    ftp://sourceware.cygnus.com/pub/egcs/infrastructure/autogen.tar.gz
> 
> Under optimization levels 2 and above, the value for "pzDta" is
> apparently stored in both a register and in memory _AND_ they are
> not kept in sync.  Here is an example from autogen/tests/evalstr.test:

I believe the above observation is essentially correct.  However, it
is the synchronization between two registers rather than register and
memory.  At -O2 and above, additional registers are used to hold pz-1
and pzDta-1.  These registers are not properly kept in sync with the
registers used for pz and pzDta.

I created this test program:

#define NUL 0
void loop (char * pz, char * pzDta)
{
    for (;;) {
        switch (*(pz++) = *(pzDta++)) {
        case NUL:
            goto loopDone2;

        case '"':
        case '\\':
            pz[-1]  = '\\';
            *(pz++) = pzDta[-1];
        }
    } loopDone2:;
}

Here is the assembler code at -O1:

[[omitted]]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]