Sujet : Re: unaligned load/store
De : anton (at) *nospam* mips.complang.tuwien.ac.at (Anton Ertl)
Groupes : comp.archDate : 22. Dec 2024, 12:06:26
Autres entêtes
Organisation : Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID : <2024Dec22.120626@mips.complang.tuwien.ac.at>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : xrn 10.11
Thomas Koenig <
tkoenig@netcologne.de> writes:
ABIs, however, generally require natural alignment for types, so
the point is somehwat moot, at least where user code is concerned.
Let's weaken this to "good ABIs require natural alignment for basic
types". Intel has erred in both directions:
* In its IA32 ABI, they required 4-byte alignment for 8-byte FP data,
while their hardware traps (with the AC flag set) when accessing an
8-byte FP value on a 4-byte-aligned address that is not
8-byte-aligned. This makes the AC flag useless.
* They made SSE/SSE2 instructions require 16-byte alignment
irrespective of the basic data type; as a result, at leas one AMD64
ABI requires 16-byte alignment of the stack on call boundaries,
which means that many functions have to adjust the stack pointer in
order to reach that alignment (the CALL instruction changes the
stack pointer by 8). That's apparently based on the theory that
using load and op and movdqa is faster than movdqu, which is
questionable <
https://www.complang.tuwien.ac.at/anton/autovectors/>.
I think
the VAX was the last major architecture which specified unaligned
struct access.
The 4-byte alignment for 8-byte floats on IA-32 also holds for struct
fields.
- anton
-- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>