https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109527
Bug ID: 109527 Summary: redundant register assignment Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vanyacpp at gmail dot com Target Milestone: --- On this function short test(short* a) { *a = 1; return *a; } latest gcc -O2 generates: test(short*): mov eax, 1 mov WORD PTR [rdi], ax mov eax, 1 ret I believe the second assignment to eax is redundant and can be removed: test(short*): mov eax, 1 mov WORD PTR [rdi], ax ret