3 ms·
On x86, most memory can be accessed unaligned (and, unless you cross a cache line boundary, there's effectively no penalty. If you're on Haswell or newer, even
by jcranmer 10y ago
On x86, most memory can be accessed unaligned (and, unless you cross a cache line boundary, there's effectively no penalty. If you're on Haswell or newer, even if you cross a cache line boundary, there's no latency hit for an L1 cache hit).
The code for a struct { char a; double b; } load reference on x86-64 after -O3 is:
movsd 1(%rdi), %xmm0
So it looks like gcc is able to condense the load on platforms with unaligned accesses. On ARM, it does look like the double is loaded byte-by-byte.
- minipci1321 10y ago> So it looks like gcc is able to condense the load on platforms with unaligned accesses. It seems there are still some leftovers -- try: struct { int i:31; }; with and without __attribute__((__packed__)).