This is the mail archive of the 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]
Other format: [Raw text]

SPARC code inefficiency

The source code below comes from md5.c from gnupg. 
The code is compiled with gcc-3.1 -O2 on sparc
(adding -mcpu=v8 or ultrasparc doesn't change much)

Look at all the uses for the %o2 register:

32 lines matching "o2" in buffer md5.s.
     11:	add	%fp, -80, %o2
     21:	mov	%o2, %i5
     40:	ld	[%o2], %i0
     53:	add	%o2, 4, %o2
     54:	ld	[%o2], %i0
     67:	add	%o2, 4, %o2
     68:	ld	[%o2], %i0
     81:	add	%o2, 4, %o2
     82:	ld	[%o2], %i0
     95:	add	%o2, 4, %o2
     96:	ld	[%o2], %i0
    109:	add	%o2, 4, %o2
    110:	ld	[%o2], %i0
    123:	add	%o2, 4, %o2
    124:	ld	[%o2], %i0
    137:	add	%o2, 4, %o2
    138:	ld	[%o2], %i0
    151:	add	%o2, 4, %o2
    152:	ld	[%o2], %i0
    165:	add	%o2, 4, %o2
    166:	ld	[%o2], %i0
    179:	add	%o2, 4, %o2
    180:	ld	[%o2], %i0
    193:	add	%o2, 4, %o2
    194:	ld	[%o2], %i0
    207:	add	%o2, 4, %o2
    208:	ld	[%o2], %i0
    221:	add	%o2, 4, %o2
    222:	ld	[%o2], %i0
    234:	add	%o2, 4, %o2
    236:	ld	[%o2], %i0
    249:	ld	[%o2+4], %i0

all the above "add" instructions can be eliminated by using a reg + offset
addressing mode. 

Adding some peephole2s could solve this... Is there a better way? 

The source code and assembly are attached. 

Attachment: md5.i
Description: md5.i

Attachment: md5.s
Description: md5.s

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