Unaligned access trade-offs for SFrame FRE layout
Segher Boessenkool
segher@kernel.crashing.org
Tue Sep 16 16:44:26 GMT 2025
On Tue, Sep 16, 2025 at 09:32:30AM -0700, Fangrui Song wrote:
> The read32le(p) function is either a standard read or a byte-swapped
> read.
You should never overcomplicate things by doing byte-swaps. Instead,
just say what you mean:
u32 read32le(u8 *p)
{
return p[0] + 0x100*p[1] + 0x10000*p[2] + 0x1000000*p[3];
}
or something like that. The compiler can optimise such things just
fine! There is no need to go via extra indirections.
Segher
More information about the Binutils
mailing list