This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Annoying silly warning emitted by gcc?


 
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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]