On 6/6/05, Georg Bauhaus <[EMAIL PROTECTED]> wrote: > Daniel Kegel wrote: > > > So, I'm looking around for other reports of performance > > regressions in gcc-4.0. > > I came across this one: > > int foo(int a, int b) > { > return a + b; > } > > int bar() > { > int x = 0, y = 10; > int c; > > for (c=0; c < 123123123 && x > -1; ++c, --y) > x = foo(c, y); > return x; > } > > int main() > { > return bar(); > }
Interestingly for mainline with -O3 we transform main into main () { int a; int x; <bb 0>: a = 0; <L1>:; x = a + (int) (10 - (unsigned int) a); a = a + 1; if (a <= 123123122 && x > -1) goto <L1>; else goto <L3>; <L3>:; return 10; } which the RTL loop optimizer can turn into .L11: incl %eax cmpl $123123122, %eax jle .L11 4.0 is similar - there's one extra increment in the loop, while 3.4 is considerably worse: .L18: leal (%ecx,%ebx), %esi movl %esi, %eax incl %ecx decl %ebx notl %eax cmpl $123123122, %ecx setle %dl shrl $31, %eax testl %edx, %eax jne .L18 So I'd not call it a performance regression ;) Richard.