Thread View: gmane.comp.gcc.bugs
9 messages
9 total messages
Started by "Tomer.Levi at n
Wed, 26 Jan 2011 09:50
[Bug c/47470] New: Less-optimized Code Size when using Optimizations
Author: "Tomer.Levi at n
Date: Wed, 26 Jan 2011 09:50
Date: Wed, 26 Jan 2011 09:50
39 lines
1318 bytes
1318 bytes
http://gcc.gnu.org/bugzilla/show_bug.cgi?idG470 Summary: Less-optimized Code Size when using Optimizations Product: gcc Version: 3.3.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned@gcc.gnu.org ReportedBy: Tomer.Levi@nuvoton.com Created attachment 23129 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id#129 Generated Assembly with and w/o optimizations Hi, Consider the following code: int a,b,c,d; int main (void) { while (a || b || c) { if (d) break; } return 0; } When compiling w/o optimization, the produced code is even smaller than when providing optimization flags (-O<n> or -Os). It seems like when using some sort of optimization, the compiler always creates a loop pre-header. When optimized, the compiler performs a dual comparison, once in the pre-header, the other in the loop. Without optimizations, only a single comparison is used, thus code is much smaller (please see attachment for the generated assembly). Since we are very tight on code size, is there a way to force the compiler to avoid the usage of such a pre-header while using -Os optimization? I haven't found any flag/switch for that. Thanks in advance.
[Bug c/47470] Less-optimized Code Size when using Optimizations
Author: "mikpe at it dot
Date: Wed, 26 Jan 2011 10:17
Date: Wed, 26 Jan 2011 10:17
6 lines
321 bytes
321 bytes
http://gcc.gnu.org/bugzilla/show_bug.cgi?idG470 --- Comment #1 from Mikael Pettersson <mikpe at it dot uu.se> 2011-01-26 10:17:18 UTC --- gcc-3.3.2 is ancient and no longer supported upstream. Please try gcc-4.4.5 or newer. Also you haven't told us which target you're compiling for, or how your gcc was configured.
[Bug c/47470] Less-optimized Code Size when using Optimizations
Author: "Tomer.Levi at n
Date: Wed, 26 Jan 2011 11:43
Date: Wed, 26 Jan 2011 11:43
23 lines
955 bytes
955 bytes
http://gcc.gnu.org/bugzilla/show_bug.cgi?idG470 --- Comment #2 from Tomer Levi <Tomer.Levi at nuvoton dot com> 2011-01-26 11:43:36 UTC --- Hi, The attached assembly was produced on the following machine: taln36-Amit<1015> gcc -v Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs Configured with: ./configure -prefix=/usr/ : (reconfigured) ./configure : (reconfigured) ./configure : (reconfigured) ./configure Thread model: single gcc version 3.1 In specific, i'm using CR16 architecture, which is based on GCC 3.3.2 (compiler backend is not under GNU, only Binutils). However, the behavior i'm describing is not related to the backend. I have no GCC 4.* installed, hence do not know whether the described behavior is reproducible using the latest compiler. I'll appreciate if you can verify this. BTW, is my assumption regarding loop pre-header is correct? If so, is there any way to avoid it, thus to save code size? Thanks.
[Bug c/47470] Less-optimized Code Size when using Optimizations
Author: "mikpe at it dot
Date: Wed, 26 Jan 2011 12:23
Date: Wed, 26 Jan 2011 12:23
15 lines
560 bytes
560 bytes
http://gcc.gnu.org/bugzilla/show_bug.cgi?idG470 --- Comment #3 from Mikael Pettersson <mikpe at it dot uu.se> 2011-01-26 12:23:03 UTC --- (In reply to comment #2) > Hi, > The attached assembly was produced on the following machine: > > taln36-Amit<1015> gcc -v > Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs > Configured with: ./configure -prefix=/usr/ : (reconfigured) ./configure : > (reconfigured) ./configure : (reconfigured) ./configure > Thread model: single > gcc version 3.1 Do that for your cross-gcc to cr16 instead.
[Bug c/47470] Less-optimized Code Size when using Optimizations
Author: "Tomer.Levi at n
Date: Wed, 26 Jan 2011 12:47
Date: Wed, 26 Jan 2011 12:47
13 lines
716 bytes
716 bytes
http://gcc.gnu.org/bugzilla/show_bug.cgi?idG470 --- Comment #4 from Tomer Levi <Tomer.Levi at nuvoton dot com> 2011-01-26 12:47:14 UTC --- The cross-gcc compiler i'm using is hooking the default GNU verbose message, hence i can not tell how GCC was exactly configured. As i alredy said, the issue is reproducible on native GCC (i686-pc-linux-gnu), so the target i'm using is not necessarily relevant here. I'm just looking for a way to alter the compiler's behavior. I think the cross-target is configured as follows: ../$(GCC_DIR)/configure --target=cr16c --enable-languages=c,c++ --disable-checking --prefix=$(PREFIX) --with-as=$(PREFIX)/bin/crasm --with-ld=$(PREFIX)/bin/crld --with-headers=$(PREFIX)/include
[Bug c/47470] Less-optimized Code Size when using Optimizations
Author: "rguenth at gcc
Date: Wed, 26 Jan 2011 12:51
Date: Wed, 26 Jan 2011 12:51
4 lines
223 bytes
223 bytes
http://gcc.gnu.org/bugzilla/show_bug.cgi?idG470 --- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-01-26 12:50:57 UTC --- Try -fno-loop-optimize (or -fno-loop-optimize2 if that is already available).
[Bug c/47470] Less-optimized Code Size when using Optimizations
Author: "Tomer.Levi at n
Date: Wed, 26 Jan 2011 13:00
Date: Wed, 26 Jan 2011 13:00
10 lines
447 bytes
447 bytes
http://gcc.gnu.org/bugzilla/show_bug.cgi?idG470 --- Comment #6 from Tomer Levi <Tomer.Levi at nuvoton dot com> 2011-01-26 13:00:17 UTC --- Hi Richard, Thanks for your prompt reply. Actually, -fno-loop-optimize was the first thing i've tried when facing this issue. However, the generated code is even worse than using -Os alone. The loop pre-header still appears, meaning dual comparison. -fno-loop-optimize2 is not supported under GCC 3.3.2.
[Bug c/47470] Less-optimized Code Size when using Optimizations
Author: "Tomer.Levi at n
Date: Wed, 26 Jan 2011 13:16
Date: Wed, 26 Jan 2011 13:16
9 lines
464 bytes
464 bytes
http://gcc.gnu.org/bugzilla/show_bug.cgi?idG470 --- Comment #7 from Tomer Levi <Tomer.Levi at nuvoton dot com> 2011-01-26 13:16:16 UTC --- Hi, I was able to test the behavior on GCC 3.4.5 (native): Here, the -fno-loop-optimize (and -fno-loop-optimize2) generate an optimized code as expected. Unfortunately, i don't have a GCC 3.3.2 native installation, hence i can't verify whether the behavior i'm seeing using my cross-gcc is due to the frontend or backend.
[Bug c/47470] Less-optimized Code Size when using Optimizations
Author: "rguenth at gcc
Date: Wed, 26 Jan 2011 13:37
Date: Wed, 26 Jan 2011 13:37
28 lines
1006 bytes
1006 bytes
http://gcc.gnu.org/bugzilla/show_bug.cgi?idG470 Richard Guenther <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |FIXED --- Comment #8 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-01-26 13:37:50 UTC --- You can also try -fno-thread-jumps, but really we don't care about 3.x anymore and for example 4.5.1 creates reasonable code for me on i?86-linux. > gcc-4.5 -c t.c -m32 -Os > size t.o text data bss dec hex filename 50 0 0 50 32 t.o > gcc-3.3 -c t.c -m32 -Os > size t.o text data bss dec hex filename 70 0 0 70 46 t.o > gcc-3.3 -c t.c -m32 > size t.o text data bss dec hex filename 73 0 0 73 49 t.o Thus closing as fixed.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads