https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81456
LIU Hao <lh_mouse at 126 dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lh_mouse at 126 dot com --- Comment #12 from LIU Hao <lh_mouse at 126 dot com> --- Is this the same issue? https://gcc.godbolt.org/z/sTs3E9EP1 ``` struct stack { void** base; unsigned int top, cap; }; struct context { void* data; stack* st; }; int clear_stack(context& ctx) { ctx.st->top = 0; return 0; } ``` GCC reuses RAX for `ctx.st` and the return value, so an extra XOR is generated: ``` clear_stack(context&): mov rax,QWORD PTR [rdi+0x8] xor edx,edx <-- this would be unnecessary if `xor eax, eax` was lifted here mov DWORD PTR [rax+0x8],edx xor eax,eax ret ``` as in ``` clear_stack_2(context&): mov rcx,QWORD PTR [rdi+0x8] # 48 8b 4f 08 xor eax,eax # 31 c0 mov DWORD PTR [rcx+0x8],eax # 89 41 08 ret # c3 ```