3.4.3 generates code which may be ~6x+ slower and larger than 3.3.1 @ -0s
as it apparently no longer evaluates constant expression trees in anything
other than simple expressions for some reason, which may result in serious
performance and code size regressions, which should really be fixed if possible.
// 000000c6 <foo>:
int foo ( int a ){
if (a & (1L << 23))
// c6: aa 27 eor r26, r26
// c8: 97 fd sbrc r25, 7
// ca: a0 95 com r26
// cc: ba 2f mov r27, r26
// ce: 27 e1 ldi r18, 0x17 ; 23
// d0: b6 95 lsr r27
// d2: a7 95 ror r26
// d4: 97 95 ror r25
// d6: 87 95 ror r24
// d8: 2a 95 dec r18
// da: d1 f7 brne .-12 ; 0xd0
// dc: 81 70 andi r24, 0x01 ; 1
// de: 90 70 andi r25, 0x00 ; 0
// e0: 89 2b or r24, r25
// e2: 19 f0 breq .+6 ; 0xea
return 1;
// e4: 81 e0 ldi r24, 0x01 ; 1
// e6: 90 e0 ldi r25, 0x00 ; 0
// e8: 08 95 ret
else
return 2 ;
// ea: 82 e0 ldi r24, 0x02 ; 2
// ec: 90 e0 ldi r25, 0x00 ; 0
}
// ee: 08 95 ret
// f0: 08 95 ret
// where the second return is odd as well?
vs GCC 3.3.1 @ -0s
// 000000c6 <foo>:
int foo2 ( int a ){
if (a & (1L << 23))
return 1;
else
return 2 ;
}
// c6: 82 e0 ldi r24, 0x02 ; 2
// c8: 90 e0 ldi r25, 0x00 ; 0
// ca: 08 95 ret
(where for referance int targeted to avr is 16-bits wide,
but the above problem is not likely target sensitive.)
--
Summary: 3.4.3 ~6x+ performance regression vs 3.3.1, constant
trees not being computed.
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Severity: critical
Priority: P1
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: schlie at comcast dot net
CC: dmixm at marine dot febras dot ru,ericw at evcohs dot
com,gcc-bugs at gcc dot gnu dot org
GCC build triplet: any
GCC host triplet: any
GCC target triplet: avr-unknown-none
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18424