[Bug middle-end/67606] Missing optimization: load possible return value before early-out test

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Aug 13 05:32:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67606

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note -O2 is fine, it is just -O3 which is worse.
-O2 with the trunk 4 days ago on aarch64-linux-gnu:
f:
        mov     x4, x0
        cmp     w1, 0
        ble     .L5
        mov     x2, 0
        mov     w0, 0
        .p2align 3
.L4:
        ldr     w3, [x4, x2, lsl 2]
        add     x2, x2, 1
        cmp     w3, 6
        cinc    w0, w0, ge
        cmp     w1, w2
        bgt     .L4
        ret
        .p2align 3
.L5:
        mov     w0, 0
        ret

-O3 -fno-tree-vectorize :
f:
        mov     x4, x0
        cmp     w1, 0
        ble     .L7
        mov     x2, 0
        mov     w0, 0
        .p2align 3
.L3:
        ldr     w3, [x4, x2, lsl 2]
        add     x2, x2, 1
        cmp     w3, 5
        ble     .L4
        add     w0, w0, 1
        cmp     w1, w2
        bgt     .L3
        ret
        .p2align 3
.L4:
        cmp     w1, w2
        bgt     .L3
        ret
        .p2align 3
.L7:
        mov     w0, 0
        ret

Oh it is worse since tracer happens at -O3 but ifconvert happens later.


More information about the Gcc-bugs mailing list