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]

Suboptimal code generated for _Bool


This module:

#include <stdbool.h>
bool test1(int x) {return x == 5;}
bool test2(int x) {return test1(x);}

is compiled by gcc-3.4.0 on x86, invoked by
'gcc -S -O2 -fomit-frame-pointer bool.c',
to the following code:

[...]
test2:
        subl    $4, %esp
        movl    8(%esp), %eax
        movl    %eax, (%esp)
        call    test1
        addl    $4, %esp
        movzbl  %al, %eax
        ret

The movzbl is completely unnecessary. It's inserted even if the called
function is inline.

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak@knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/


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