|Summary:||-Os creates larger binaries than before in some cases (-falign-... options enabled)|
|Component:||middle-end||Assignee:||Not yet assigned to anyone <unassigned>|
|Build:||Known to work:|
|Known to fail:||Last reconfirmed:|
|Attachments:||Disable alignment when using -Os|
Description rwahl 2010-04-22 23:48:23 UTC
Hi, I just noticed that some of my libraries are greater when compiled with gcc 4.4.3 instead of gcc 4.3.2. Diffing the output of "gcc --help=optimizers -Q -Os" shows this in 4.3.2: -falign-jumps [disabled] -falign-labels [disabled] -falign-loops [enabled] and this for 4.4.3: -falign-functions [enabled] -falign-jumps [enabled] -falign-labels [enabled] -falign-loops [disabled] when explicitely disabling the alignment options then the code size shrinks. For libxml2 in my case from 704256 to 675584 bytes. The manual says: -Os disables the following optimization flags: -falign-functions -falign-jumps -falign-loops -falign-labels -freorder-blocks -freorder-blocks-and-partition -fprefetch-loop-arrays -ftree-vect-loop-version which is not true (even not for 4.3.2 since loop alignment was enabled). Some other opts like -freorder-blocks is enabled as well. So is this actually a bug or is the documentation outdated or even both?
Comment 1 firstname.lastname@example.org 2010-04-22 23:51:39 UTC
Subject: Re: New: -Os creates larger binaries than before in some cases (-falign-... options enabled) Which target is this for? Sent from my iPhone On Apr 22, 2010, at 4:48 PM, "rwahl at gmx dot de" <email@example.com > wrote: > Hi, > > I just noticed that some of my libraries are greater when compiled > with gcc > 4.4.3 instead of gcc 4.3.2. Diffing the output of "gcc -- > help=optimizers -Q > -Os" shows this in 4.3.2: > > -falign-jumps [disabled] > -falign-labels [disabled] > -falign-loops [enabled] > > and this for 4.4.3: > > -falign-functions [enabled] > -falign-jumps [enabled] > -falign-labels [enabled] > -falign-loops [disabled] > > when explicitely disabling the alignment options then the code size > shrinks. > For libxml2 in my case from 704256 to 675584 bytes. > > The manual says: > > -Os disables the following optimization flags: -falign-functions > -falign-jumps -falign-loops -falign-labels -freorder- > blocks > -freorder-blocks-and-partition -fprefetch-loop-arrays > -ftree-vect-loop-version > > which is not true (even not for 4.3.2 since loop alignment was > enabled). Some > other opts like -freorder-blocks is enabled as well. > > So is this actually a bug or is the documentation outdated or even > both? > > > -- > Summary: -Os creates larger binaries than before in some > cases (- > falign-... options enabled) > Product: gcc > Version: 4.4.3 > Status: UNCONFIRMED > Severity: normal > Priority: P3 > Component: middle-end > AssignedTo: unassigned at gcc dot gnu dot org > ReportedBy: rwahl at gmx dot de > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43861 >
Comment 2 rwahl 2010-04-23 00:10:32 UTC
All my own cross compilers for ARM and x86 hosted on x86 and the native gcc in Fedora 12 (x86) show this behavior.
Comment 3 rwahl 2010-05-02 16:55:19 UTC
Created attachment 20535 [details] Disable alignment when using -Os The attached patch fixes the problem. It could be written in a more elegant way by changing just opt1_max but this would modify the semantic of this variable and it should be renamed accordingly. On ARM the fix is probably a NOP because the default alignment seems to be 1 anyway but I haven't checked this. The output of "gcc -Q --help=optimizers" seems to be broken for the alignment options because on one hand these options are not boolean and on the other hand falign-loops is reported as enabled when it has been disabled and vice versa.