This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/18424] [3.4/4.0 Regression] ~6x+ performance regression, constant trees not being computed.
- From: "roger at eyesopen dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Dec 2004 15:00:02 -0000
- Subject: [Bug middle-end/18424] [3.4/4.0 Regression] ~6x+ performance regression, constant trees not being computed.
- References: <20041111023501.18424.schlie@comcast.net>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From roger at eyesopen dot com 2004-12-09 14:59 -------
The patch is a "partial" fix as there will still be a performance regression for
the code generated vs. gcc 3.3.1. The reason being that 3.3.1 generated
incorrect code for test program in this PR.
int foo(int a) { return (a & (1L<<23)) ? 1 : 2; }
is supposed to sign-extend "a" from a 16-bit integer to a 32-bit long, to match
the (long) constant operand. This sign-extension may end setting bit 23, so the
result of the function is dependent upon "a". i.e. the best we can do is:
int foo(int a) { return (a < 0) ? 1 : 2; }
Unfortunately, we don't quite get that efficient for avr-elf, instead still
producing the sign-extension and an AND by constant. This fixes the regression
aspects of this patch, but we still have a missed optimization. The code we
generate is:
clr r26
sbrc r25,7
com r26
mov r27,r26
sbrs r26,7
rjmp .L2
ldi r24,lo8(1)
ldi r25,hi8(1)
ret
.L2:
ldi r24,lo8(2)
ldi r25,hi8(2)
ret
Perhaps once the patch is committed, we should close this PR, and open a
separate "enhancement" request PR to catch this missed AND(SIGN_EXTEND ..))
opportunity on AVR.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18424