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: unassig...@gcc.gnu.org
        ReportedBy: tomer.l...@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.

Reply via email to