This is the mail archive of the gcc-bugs@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]

[Bug rtl-optimization/19719] New: missed optimization on boolean operation with boolean arguments


Function:
bool f(bool b1, bool b2) { return (b1 && b2); }

compiled into assembly with 2 jumps and many redundand instructions (7 total),
see below.

Should be no jumps and much less instructins (3 total).

Yuri


----got from g++----
        pushl   %ebp
        movl    %esp, %ebp
>        xorl    %eax, %eax
>        cmpb    $0, 8(%ebp)
>        movb    12(%ebp), %dl
>        je      .L2
>        testb   %dl, %dl
>        je      .L2
>        movb    $1, %al
        .p2align 2,,3
.L2:
        leave
        ret

----should be----
       pushl   %ebp
        movl    %esp, %ebp
>        xorl    %eax, %eax
>        movb    8(%ebp), %al
>        andb    12(%ebp), %al
        .p2align 2,,3
.L2:
        leave
        ret

-- 
           Summary: missed optimization on boolean operation with boolean
                    arguments
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: yuri at tsoft dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19719


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