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

GCC for MIPS not using the right registers?


I'm producing MIPS code with gcc 4.3.3, specifically on the PSP.

When I started looking over the output, I started noticing a strange
pattern: the code is often using the s registers which need to be saved
rather than the t registers which don't. This produces code that constantly
needs to save and load the s registers for no discernible reason -- a huge
waste of cycles!

This happens regardless of the optimization level (though I haven't tried
O0)

Here's an example. Notice that only t0 is used, and the compiler chooses to
use all the s registers instead. Notice how inefficient the code becomes:

089033e4 <_ZN9PspMemory8testCopyEPKhS1_j>:
 89033e4:	27bdffd8 	addiu	sp,sp,-40
 89033e8:	afb60018 	sw	s6,24(sp)
 89033ec:	00a0b021 	move	s6,a1
 89033f0:	3c0508ac 	lui	a1,0x8ac
 89033f4:	afb7001c 	sw	s7,28(sp)
 89033f8:	afb40010 	sw	s4,16(sp)
 89033fc:	0080b821 	move	s7,a0
 8903400:	00c0a021 	move	s4,a2
 8903404:	24a595c8 	addiu	a1,a1,-27192
 8903408:	24040001 	li	a0,1
 890340c:	afbf0024 	sw	ra,36(sp)
 8903410:	afbe0020 	sw	s8,32(sp)
 8903414:	afb50014 	sw	s5,20(sp)
 8903418:	afb3000c 	sw	s3,12(sp)
 890341c:	afb20008 	sw	s2,8(sp)
 8903420:	afb10004 	sw	s1,4(sp)
 8903424:	0e242f24 	jal	890bc90 <_Z13PspDebugTracebPKcz>
 8903428:	afb00000 	sw	s0,0(sp)
 890342c:	12800036 	beqz	s4,8903508 <_ZN9PspMemory8testCopyEPKhS1_j+0x124>
 8903430:	3c0208ac 	lui	v0,0x8ac
 8903434:	2455961c 	addiu	s5,v0,-27108
 8903438:	3c0208ac 	lui	v0,0x8ac
 890343c:	245e95fc 	addiu	s8,v0,-27140
 8903440:	02e09021 	move	s2,s7
 8903444:	02c08821 	move	s1,s6
 8903448:	00009821 	move	s3,zero
 890344c:	0a240d1e 	j	8903478 <_ZN9PspMemory8testCopyEPKhS1_j+0x94>
 8903450:	00008021 	move	s0,zero
 8903454:	02003021 	move	a2,s0
 8903458:	24040001 	li	a0,1
 890345c:	0e242f24 	jal	890bc90 <_Z13PspDebugTracebPKcz>
 8903460:	02a02821 	move	a1,s5
 8903464:	26100001 	addiu	s0,s0,1
 8903468:	0214102b 	sltu	v0,s0,s4
 890346c:	26520001 	addiu	s2,s2,1
 8903470:	10400015 	beqz	v0,89034c8 <_ZN9PspMemory8testCopyEPKhS1_j+0xe4>
 8903474:	26310001 	addiu	s1,s1,1
 8903478:	92480000 	lbu	t0,0(s2)
 890347c:	92270000 	lbu	a3,0(s1)
 8903480:	5107fff9 	beql	t0,a3,8903468 <_ZN9PspMemory8testCopyEPKhS1_j+0x84>
 8903484:	26100001 	addiu	s0,s0,1
 8903488:	1660fff3 	bnez	s3,8903458 <_ZN9PspMemory8testCopyEPKhS1_j+0x74>
 890348c:	02003021 	move	a2,s0
 8903490:	3c0508ac 	lui	a1,0x8ac
 8903494:	24040001 	li	a0,1
 8903498:	0e242f24 	jal	890bc90 <_Z13PspDebugTracebPKcz>
 890349c:	24a595dc 	addiu	a1,a1,-27172
 89034a0:	02c03821 	move	a3,s6
 89034a4:	02804021 	move	t0,s4
 89034a8:	24040001 	li	a0,1
 89034ac:	03c02821 	move	a1,s8
 89034b0:	0e242f24 	jal	890bc90 <_Z13PspDebugTracebPKcz>
 89034b4:	02e03021 	move	a2,s7
 89034b8:	24130001 	li	s3,1
 89034bc:	92270000 	lbu	a3,0(s1)
 89034c0:	0a240d15 	j	8903454 <_ZN9PspMemory8testCopyEPKhS1_j+0x70>
 89034c4:	92480000 	lbu	t0,0(s2)
 89034c8:	1260000f 	beqz	s3,8903508 <_ZN9PspMemory8testCopyEPKhS1_j+0x124>
 89034cc:	3c0508ac 	lui	a1,0x8ac
 89034d0:	8fbf0024 	lw	ra,36(sp)
 89034d4:	8fbe0020 	lw	s8,32(sp)
 89034d8:	8fb7001c 	lw	s7,28(sp)
 89034dc:	8fb60018 	lw	s6,24(sp)
 89034e0:	8fb50014 	lw	s5,20(sp)
 89034e4:	8fb40010 	lw	s4,16(sp)
 89034e8:	8fb3000c 	lw	s3,12(sp)
 89034ec:	8fb20008 	lw	s2,8(sp)
 89034f0:	8fb10004 	lw	s1,4(sp)
 89034f4:	8fb00000 	lw	s0,0(sp)
 89034f8:	24a59c8c 	addiu	a1,a1,-25460
 89034fc:	24040001 	li	a0,1
 8903500:	0a242f24 	j	890bc90 <_Z13PspDebugTracebPKcz>
 8903504:	27bd0028 	addiu	sp,sp,40
 8903508:	3c0508ac 	lui	a1,0x8ac
 890350c:	8fbf0024 	lw	ra,36(sp)
 8903510:	8fbe0020 	lw	s8,32(sp)
 8903514:	8fb7001c 	lw	s7,28(sp)
 8903518:	8fb60018 	lw	s6,24(sp)
 890351c:	8fb50014 	lw	s5,20(sp)
 8903520:	8fb40010 	lw	s4,16(sp)
 8903524:	8fb3000c 	lw	s3,12(sp)
 8903528:	8fb20008 	lw	s2,8(sp)
 890352c:	8fb10004 	lw	s1,4(sp)
 8903530:	8fb00000 	lw	s0,0(sp)
 8903534:	24a59628 	addiu	a1,a1,-27096
 8903538:	24040001 	li	a0,1
 890353c:	0a242f24 	j	890bc90 <_Z13PspDebugTracebPKcz>
 8903540:	27bd0028 	addiu	sp,sp,40



-- 
View this message in context: http://old.nabble.com/GCC-for-MIPS-not-using-the-right-registers--tp29293261p29293261.html
Sent from the gcc - bugs mailing list archive at Nabble.com.


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