This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: How avoid bad optimization in gcc >= 4.3?
- From: Andrew Haley <aph at redhat dot com>
- To: Georg-Johann Lay <avr at gjlay dot de>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 22 Dec 2008 12:59:44 +0000
- Subject: Re: How avoid bad optimization in gcc >= 4.3?
- References: <494F8ACB.8000009@gjlay.de>
Georg-Johann Lay wrote:
> is there a way to prevent gcc 4.3.x from doing bad optimizations?
We don't have a -fno-bad-optimizations flag; patches welcome!
> I attached an example that shows the performance degradation for
> a source compiled with -Os (-O2 is similar) for target avr.
>
> The code from the new compiler increased by at about 30%
> with respect to good old 3.4.6 and needs more as double
> of stack slots (13 instead of 6).
>
> text data bss dec hex filename
> 156 0 0 156 9c foo-3.4.6.o
> 206 0 0 206 ce foo-4.3.2.o
>
> Moreover, it expands a rather trivial address computation into a
> multiplication on a target without hardware multiplier, so
> there is additional, unacceptable time and code penalty
> caused by a call to __mulhi3 from libgcc2.
>
> The multiplication is by -2, i.e. trivial
This is strange. Can you provide an example of that address
computation as a test case?
Make it just a few lines long, please.
Andrew.