[Bug tree-optimization/93056] Poor codegen for heapsort in stephanov_vector benchmark

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jan 31 09:25:00 GMT 2020


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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-01-31
     Ever confirmed|0                           |1

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, reduced testcase:
void f(int *begin, int free, int count)
{
    for ( int i = 2*(free+1); i < count; i += i) {
        if ( *(begin+(i-1)) < *(begin+i))
            i++;
        *(begin + free) = *(begin+(i-1));
        free = i-1;
  }
}

For -O1, we get:
.L4:
        add     x4, x0, x3, sxtw 2
        ldr     w5, [x4, -4]
        ldr     w4, [x0, w3, sxtw 2]
        cmp     w5, w4
        cinc    w3, w3, lt
        add     x4, x0, x3, sxtw 2
        ldr     w4, [x4, -4]
        str     w4, [x0, w1, sxtw 2]
        sub     w1, w3, #1
        lsl     w3, w3, 1
        cmp     w2, w3
        bgt     .L4

--- CUT ---
For -O2 we get:
.L2:
        add     x4, x0, x3, sxtw 2
        ldr     w5, [x0, w3, sxtw 2]
        mov     w7, w3
        add     w6, w3, 1
        ldr     w4, [x4, -4]
        cmp     w4, w5
        blt     .L4
        mov     w5, w4
        sub     w7, w3, #1
        mov     w6, w3
.L4:
        str     w5, [x0, w1, sxtw 2]
        lsl     w3, w6, 1
        mov     w1, w7
        cmp     w2, w3
        bgt     .L2


More information about the Gcc-bugs mailing list