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

            Bug ID: 126208
           Summary: [17 Regression] Missed beneficial path splitting in
                    libquantum
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ktkachov at gcc dot gnu.org
  Target Milestone: ---

After removing -fsplit-paths in GCC 17 (PR120892)
we have a 3% regression on aarch64 in libquantum from SPEC2006:
https://gcc.gnu.org/pipermail/gcc-patches/2026-July/723522.html

The reduced tescase is:
void
update (long **nodes, int *size)
{
  for (int i = 0; i < *size; ++i)
    if ((*nodes)[i])
      (*nodes)[i] = 0;
}

compiled with -O3 -fno-strict-aliasing .
The before (good) code is:
update(long**, int*):
        ldr     w6, [x1]
        cmp     w6, 0
        ble     .L1
        ldr     x4, [x0]
        mov     x2, 0
.L5:
        ubfiz   x3, x2, 3, 32
        ldr     x5, [x4, x3]
        cbz     x5, .L3
.L8:
        str     xzr, [x4, x3]
        add     x2, x2, 1
        ldr     w6, [x1]
        cmp     w6, w2
        ble     .L1
        ldr     x4, [x0]
        ubfiz   x3, x2, 3, 32
        ldr     x5, [x4, x3]
        cbnz    x5, .L8
.L3:
        add     x2, x2, 1
        cmp     w6, w2
        bgt     .L5
.L1:
        ret

and the bad (after, GCC 17) code is:
update(long**, int*):
        ldr     w6, [x1]
        cmp     w6, 0
        ble     .L1
        mov     w2, 0
.L4:
        ldr     x4, [x0]
        ubfiz   x3, x2, 3, 32
        add     x2, x2, 1
        ldr     x5, [x4, x3]
        cbz     x5, .L3
        str     xzr, [x4, x3]
        ldr     w6, [x1]
.L3:
        cmp     w6, w2
        bgt     .L4
.L1:
        ret

GCC 16 with -fsplit-paths managed to avoid a pointer-chasing load of x4 in
every iteration of the hot loop.

Reply via email to