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

--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jeff Law <[email protected]>:

https://gcc.gnu.org/g:50fa5ffebbd6dc02dd045fff75923a5409d9f169

commit r17-6602-g50fa5ffebbd6dc02dd045fff75923a5409d9f169
Author: Yongqiang Tian <[email protected]>
Date:   Mon Nov 23 09:15:30 2026 -0700

    [PATCH v2] sched-rgn: Count non-debug insns in region size estimate
[PR128860]

    rgn_estimate_number_of_insns used the LUID span of a block and then
    subtracted the debug insns in it.  Notes take the LUID of the following
    insn, so when the last non-debug element of a block is a note, the
    debug insns after it were subtracted once too often.  A block with only
    debug insns was counted as -1 insns with -g and 0 with -g0, and
    too_large could accept a region with -g only.

    Count the non-debug insns directly instead.  The exact count is normally
    one greater than the previous LUID-span estimate, so this also increases
    the -g0 estimate by one for most blocks.

    Regression tested on an aarch64-linux-gnu cross compiler (c, c++) with
    binutils and glibc, running execution tests under qemu-user.  No existing
    test result changed; the patched tree additionally passes the new test.

    Assisted-by: Claude Opus 5.5, co-reviewed by OpenAI Codex 5.6 Sol and
Yongqiang Tian.

    ---
    v2: Count non-debug insns directly, as suggested by Richard.

    I also logged every call to estimate_number_of_insns while compiling the
    13,579 files in gcc.dg, gcc.dg/torture, and gcc.c-torture on the
    aarch64-linux-gnu cross:

                                                 Calls    Blocks   Maximum
      -O2 -fschedule-insns                       14,022    14,022         1
      -O3 -funroll-loops -fschedule-insns        11,491    11,491         1
      -O2, region extension, 2 iterations        64,714    59,022         2
      -O3, region extension, 10 iterations       68,828    63,718         2

    Without region extension, every block was estimated exactly once.  With
    region extension enabled, some blocks were estimated twice: once in
    find_rgns and once when extend_rgns assembled the extended regions.  No
    block was estimated more than twice in this corpus.  The largest run
    averaged about 1.08 calls per block, so a cache does not appear worthwhile
    for this workload.

    I also compared the -g0 assembly before and after v2 over the same corpus:

      -O2 -fschedule-insns                                      0 differences
      -O3 -funroll-loops -fschedule-insns                       1 difference
      -O2 with the test's region-extension parameters         437 differences

    The single -O3 difference is gcc.c-torture/compile/pr86637-2.c.  The
    test parameters deliberately put the region-size limit at the boundary
    exposed by the bug.  With those parameters, -fcompare-debug fails on
    pr71802.c before the change and passes after it, with no remaining failure
    in the corpus.

    The full aarch64-linux-gnu cross testsuite, including execution tests under
    qemu-user, produced:

                     gcc PASS  gcc FAIL  g++ PASS  g++ FAIL
      base             407898       133    473659         8
      v2               407899       133    473659         8

    The sorted gcc.sum and g++.sum result lines differ only by the new
    gcc.dg/pr128860.c PASS.

            PR rtl-optimization/128860

    gcc/ChangeLog:

            * sched-rgn.cc (rgn_estimate_number_of_insns): Count the
            non-debug insns instead of using the LUID span.

    gcc/testsuite/ChangeLog:

            * gcc.dg/pr128860.c: New test.

    Signed-off-by: Yongqiang Tian <[email protected]>

Reply via email to