[Bug c/32871] New: Bad optimasation - Gcc is pushing to many registers
info at umfragen-service dot de
gcc-bugzilla@gcc.gnu.org
Mon Jul 23 19:22:00 GMT 2007
Let's look at this:
long foo(long a, long b, long c, uint8_t d){
if(d){
return a+b;
}else{
return a-c;
}
}
The listing reports this:
long foo(long a, long b, long c, uint8_t d){
4e: cf 92 push r12 ;All this registers are pushed
50: ef 92 push r14 ;despite it's unessecary
52: ff 92 push r15 ;
54: 0f 93 push r16
56: 1f 93 push r17
if(d){
58: cc 20 and r12, r12
5a: 29 f0 breq .+10 ; 0x66 <foo+0x18>
return a+b;
5c: 62 0f add r22, r18
5e: 73 1f adc r23, r19
60: 84 1f adc r24, r20
62: 95 1f adc r25, r21
64: 04 c0 rjmp .+8 ; 0x6e <foo+0x20>
}else{
return a-c;
66: 6e 19 sub r22, r14
68: 7f 09 sbc r23, r15
6a: 80 0b sbc r24, r16
6c: 91 0b sbc r25, r17
6e: 1f 91 pop r17 ;And they are getting restored
70: 0f 91 pop r16 ;despite they are not changed.
72: ff 90 pop r15
74: ef 90 pop r14
76: cf 90 pop r12
78: 08 95 ret
During all operation in the low register (r3-r17) are always zero, and they are
never changed in the hole file and even not in the function itself. So it's
useless to push and pop them, we're only loosing time, space and ram.
Please excuse my bad bug-reporting-style. This is my first report. For further
explainaition I can recomment you the german site, where this problem is beeing
discussed.
http://www.roboternetz.de/phpBB2/viewtopic.php?p=300953
I hope you can fix this.
Michael
--
Summary: Bad optimasation - Gcc is pushing to many registers
Product: gcc
Version: 4.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: info at umfragen-service dot de
GCC build triplet: Linux - Slax
GCC host triplet: Linux - Slax
GCC target triplet: avr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32871
More information about the Gcc-bugs
mailing list