https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85539
Bug ID: 85539 Summary: x86_64: loads are not always narrowed Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: tilkax at gmail dot com Target Milestone: --- When casting a 64-bit memory value to 32 bits, it's possible to only load the lower 32 bits (this also avoids the REX prefix). GCC doesn't always do this: https://godbolt.org/g/EzqKNo #include <cstdint> uint32_t foo(uint64_t *p) { return *p; } Actual: mov rax, QWORD PTR [rdi] ret Expected: mov eax, DWORD PTR [rdi] ret