This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Byte swapping support

On Wed, 2017-09-13 at 13:08 +0000, wrote:
> > On Sep 13, 2017, at 5:51 AM, Jürg Billeter <> wrote:
> > To support existing large code bases, the goal is to reverse storage
> > order for all scalars, not just (selected) structs/unions. Also need to
> > support taking the address of a scalar field, for example. C++ support
> > will be required as well.
> I wonder about that.  It's inefficient to do byte swapping on local
> data; it is only useful and needed on external data.  Data that goes
> to files for use by other-byte-order applications, or data that goes
> across a bus or network to consumers that have the other byte
> order.  A byte swapped local variable only consumes cycles and
> instruction space to no purpose.

Existing code that has been written under the assumption of big-endian
memory layout can break on little-endian systems even with just local
data (e.g., accessing individual bytes of a 32-bit scalar). It would
obviously be best to fix all such code, however, that's not always
feasible, unfortunately.

Avoiding byte swapping for spilled registers where storage order is
(normally) not observable by applications will hopefully reduce the
performance overhead.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]