gcc version 4.0.0 20050203 (experimental)

The following code snippet shows how branch prediction isnt used even when
specifying builtin_expect. flags used: -O2 -mcpu=power4

#if 1
#define likely(x)       __builtin_expect(!!(x), 1)
#else
#define likely(x) x
#endif

int i;

void foo(void)
{
        while (likely(i--)) {
                bar();
        }

}

...

        b .L2
        .p2align 4,,15
.L3:
        bl bar
        nop
.L2:
        lwz 9,0(31)
        addi 9,9,-1
        extsw 9,9
        cmpwi 7,9,-1
        stw 9,0(31)
        bne 7,.L3

-- 
           Summary: __builtin_expect doesnt modify branch prediction for
                    power4 target
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: anton at samba dot org
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: powerpc64-unknown-linux-gnu


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

Reply via email to