This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Annoying silly warning emitted by gcc?
- From: Joe Buck <joe dot buck at synopsys dot com>
- To: Andrew Pinski <pinskia at gmail dot com>, Warren D Smith <warren dot wds at gmail dot com>
- Cc: GCC Mailing List <gcc at gcc dot gnu dot org>
- Date: Thu, 24 Jan 2019 01:33:35 +0000
- Subject: RE: Annoying silly warning emitted by gcc?
- References: <CAAJP7Y1Dc0DWBO7UsTcYxjsofx9a8zQOtKFc=UhvY2Ck5h3GmA@mail.gmail.com> <CA+=Sn1mSjOW7TpJ1UpcQj+DxdqcFA19-0iCefWOa3QcA7gwLBQ@mail.gmail.com>
On Wed, Jan 23, 2019 at 4:16 PM Warren D Smith <warren.wds@gmail.com> 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