This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/47470] New: Less-optimized Code Size when using Optimizations
- From: "Tomer.Levi at nuvoton dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 26 Jan 2011 09:50:30 +0000
- Subject: [Bug c/47470] New: Less-optimized Code Size when using Optimizations
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47470
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=23129
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.