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: Assignment operator


(Please do not send me extra copies of replies, I'm on the list.)

Den 12-Okt-99 01:50:28 skrev Zoltan Kocsi fĝlgende om "Re: Assignment operator":
[cut]
> If this was not the case, then of course, the usual strcpy construct

>    while ( *a++ = *b++ );
>    
> would not work since strcpy is defined to terminate on the source 
> string. Egcs, for example generates read-back of '*a' even if it 
> is not volatile, therefore if you try to copy the string to a
> write-only or volatile buffer, egcs will blow into your face. 

   There are target dependent parts of this behaviour. While the m68k (-O3
-fomit-frame-pointer -mcpu=m68060) gets

L5:
        moveb a1@+,a0@
        tstb a0@+
        jne L5

in the inner loop, the PPC (-O3 -fomit-frame-pointer -mcpu=604e) gets

.L5:
        lbz %r0,0(%r3)
        addi %r3,%r3,1		; No use of preincrement!
        mr %r9,%r0		; ???
        stb %r0,0(%r4)
        cmpwi %cr0,%r9,0
        addi %r4,%r4,1		; as above
        bc 4,2,.L5

and the sparc (-O3 -fomit-frame-pointer -mcpu=ultrasparc) gets

.LL5:
        ldub    [%o0], %g2
        sll     %g2, 24, %g3
        add     %o0, 1, %o0
        stb     %g2, [%o1]
        cmp     %g3, 0
        bne,pt  %icc, .LL5
        add     %o1, 1, %o1

instead. I.e. a readback of *a is generated on the m68k, but not on the PPC
or sparc. Fixing the amusing unoptimisation on the m68k would also remove
the readback.

Regards,

/ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻTŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ\
| Rask Ingemann Lambertsen       | E-mail: mailto:rask@kampsax.dtu.dk    |
| Please do NOT Cc: to me or the | WWW: http://www.gbar.dtu.dk/~c948374/ |
| mailing list. I am on the list.| "ThrustMe" on XPilot, ARCnet and IRC  |
|       That was a pointing device? My cat thought it was dinner.        |


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