[Bug c++/70755] [ARM] excessive struct alignment for globals

rearnsha at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Apr 22 13:22:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70755

Richard Earnshaw <rearnsha at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |arm
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #1 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
This is a deliberate design choice.  By doing this we gain significant benefits
from having aligned objects, which helps with data copying and other
optimizations.

Consider, for example, the object

struct x
{
  char a;
  char b;
  char c;
  char d;
};

struct x A, B;

f()
{
  B = A;
}

Since the objects are aligned then this function can be optimized to single
32-bit load and store operations that work very efficiently.

As you've noticed, it is possible to force the alignment down to the
architectural minimums by annotations, but for most users it makes little
difference and the defaults are preferable.


More information about the Gcc-bugs mailing list