On Wed, Jan 23, 2019 at 4:16 PM Warren D Smith <[email protected]> wrote:
>
> x = x^x;
>
> The purpose of the above is to load "x" with zero.
Don't waste your time. Intel was offering that advice to writers of assembly
language and compilers. Gcc already does the right thing.
Try the following on an Intel/AMD machine:
% cat z.c
long long zero() {
long long tmp = 0LL;
return tmp;
}
% gcc -O2 -S z.c
% cat z.s
.file "z.c"
.text
.p2align 4,,15
.globl zero
.type zero, @function
zero:
.LFB0:
.cfi_startproc
xorl %eax, %eax
ret
.cfi_endproc
.LFE0:
.size zero, .-zero
.ident "GCC: (GNU) 4.8.3"
.section .note.GNU-stack,"",@progbits