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/47253] New: Conditional jump to tail function is not generated


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

           Summary: Conditional jump to tail function is not generated
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: zsojka@seznam.cz
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu


I hope the summary is descriptive enough.
Take the following code:

----- testcase.c -----
void bar(void);

void foo(int c)
{
    if (c) bar();
}
----------------------

With -O3, gcc generated this code:
foo:
.LFB0:
    .cfi_startproc
    test    edi, edi    # c
    jne    .L4    #,
    rep
    ret
    .p2align 4,,10
    .p2align 3
.L4:
    jmp    bar    #
    .cfi_endproc


and with -Os:
foo:
.LFB0:
    .cfi_startproc
    test    edi, edi    # c
    je    .L1    #,
    jmp    bar    #
.L1:
    ret
    .cfi_endproc


while better would be:
foo:
    test    edi, edi
    jne    .L1
    rep # only without -Os
    ret

I tested 3.3.6, 3.4.6, 4.4.5, 4.6.0, neither generates the "better" code.


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