With following testcase gcc 4.1.1 with -Os produces two back-to-back jumps:
"jump to L2 if less; jump to L2 if less-or-equal;" the first one is not needed.

-O2 is worse, but I usually use -Os anyway.

void g();
void f(long long v) {
        if (v > 0777777777777LL)
                g();
        g();
}

/* gcc -v:
Target: i386-pc-linux-gnu
 [skip]
Thread model: posix
gcc version 4.1.1
================
gcc -Os -fomit-frame-pointer -S tar.c
f:
        cmpl    $15, 8(%esp)
        jl      .L2     // not needed
        jle     .L2
        call    g
.L2:
        jmp     g
================
gcc -O2 -fomit-frame-pointer -S tar.c
f:
        subl    $12, %esp       // not needed
        cmpl    $15, 20(%esp)
        jl      .L2     // not needed
        jle     .L2
        call    g
        .p2align 2,,3
.L2:
        addl    $12, %esp       // not needed
        jmp     g

*/


-- 
           Summary: suboptimal code generation
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vda dot linux at googlemail dot com
 GCC build triplet: i386-pc-linux-gnu
  GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu


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

Reply via email to