[PATCH] reorg: Ignore debug insns in delete_prior_computation [PR127795]
Yongqiang Tian
yqtian668@gmail.com
Fri Oct 9 14:04:44 GMT 2026
On 10/9/26, Jeff Law wrote:
> For future patches please note how the patch was tested.
Thanks for testing it on the delay-slot crosses and for pushing it.
Sorry for leaving that out. For this patch:
- I completed a native x86_64-pc-linux-gnu bootstrap and full
make -k check at master
54e232d0d4752b419ed775bdad50d83798fa899d, both with and without
the patch. After normalizing the build-directory path embedded in
one module test name, both runs produced the same 541,492 result
records. As you noted, this does not exercise reorg.cc.
- sparc-elf cross: the new gcc.target/sparc/reorg-delete-prior-debug.c
fails without the patch and passes with it.
- contrib/check_GNU_style.sh is clean.
I will include the testing in future submissions, and for reorg.cc
changes I will add a run of the sparc-elf cross testsuite.
> In particular the BARRIER checks in relax_delay_slots could
> potentially lead to a -fcompare-debug fail, but they'd probably need
> to be deeply evaluated to determine if a DEBUG_INSN could appear at
> that particular point in the IL.
I also found those when auditing reorg.cc. The prev_nonnote_insn
(label) BARRIER tests would only change if a DEBUG_INSN sat between a
BARRIER and the following CODE_LABEL, and I have not seen GCC put one
there. Thus I did not open a bug report for this. I can also take a second look
tomorrow.
Again, thanks a lot for looking at this.
Thanks,
Yongqiang
On Sat, 10 Oct 2026 at 00:51, Jeff Law <jeffrey.law@oss.qualcomm.com> wrote:
>
>
>
> On 10/9/26 6:38 AM, Yongqiang Tian wrote:
> > delete_prior_computation walks backward with prev_nonnote_insn while
> > deleting a dead computation. A DEBUG_INSN therefore terminates the scan
> > and can make -g retain an instruction that is deleted with -g0.
> >
> > Use prev_nonnote_nondebug_insn for both steps of the walk. Add a SPARC
> > regression test that checks both -fcompare-debug and the absence of the
> > dead add.
> >
> > Assisted-by: OpenAI Codex 5.6 Sol, co-reviewed by Claude and Yongqiang Tian.
> >
> > PR rtl-optimization/127795
> >
> > gcc/ChangeLog:
> >
> > * reorg.cc (delete_prior_computation): Ignore debug insns in the
> > backward scan.
> >
> > gcc/testsuite/ChangeLog:
> >
> > * gcc.target/sparc/reorg-delete-prior-debug.c: New test.
> >
> > Signed-off-by: Yongqiang Tian <yqtian668@gmail.com>
> Thanks. Given the patch to the compiler proper is trivial from a
> copyright standpoint it doesn't matter if it was LLM generated or not.
>
> For future patches please note how the patch was tested. Normally a
> patch to the generic part of the compiler would require a bootstrap and
> regression test on one of the primary targets such as x86 or aarch64.
> reorg.cc is pretty narrow and only used on a small number of targets and
> wouldn't be exercised during an x86 or aarch64 build. A bootstrap and
> regression test on sparc would be best, but that may not be generally
> feasible. I'm not set up for sparc testing (though there's no inherent
> reason why I couldn't set that up again....)
>
> As a quick proxy, I tested this on crosses that use delay slots. In
> particular, sh3, sh3eb, or1k, visium, microblaze, iq2000, fr30, cris,
> and arc with no regressions. So I'm confident it's behaving
> reasonably. hppa, sh4, sh4eb will give this deeper testing over the
> coming days.
>
> Your other patch fixes similar problems elsewhere in reorg.cc, I'll look
> at that patch shortly. LLM review indicates there are two similar kinds
> of instances that show up in reorg.c. In particular the BARRIER checks
> in relax_delay_slots could potentially lead to a -fcompare-debug fail,
> but they'd probably need to be deeply evaluated to determine if a
> DEBUG_INSN could appear at that particular point in the IL.
>
> I'll push this to the trunk momentarily.
>
> Thanks!
>
> jeff
More information about the Gcc-patches
mailing list