Re: [PATCH 4/4] sched-deps: record barriers once instead of per register

Jeffrey Law <[email protected]> Mon, 3 Aug 2026 23:17:35 -0600
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>

On 7/30/2026 9:28 AM, [email protected] wrote:
> From: Kyrylo Tkachov <[email protected]>
>
> Before reload, sched_analyze_insn records each barrier in every reg_last
> entry.  The next barrier can add the same dependence once per register.
> Without the dependency cache, each addition linearly searches the
> dependence list.  This can make barrier analysis quadratic in function size.
>
> For non-selective scheduling before reload, record barriers once in a
> pending list.  Treat it as the logical sets list for untouched registers
> and materialize it when a register is first touched.  Emit its dependence
> at the first gap in the ascending register walk to preserve eager order.
> Reconcile dirty-only entries and combine pending and materialized state in
> deps_join.  Keep the eager form after reload and for selective scheduling.
>
> Target-neutral RTL selftests cover full and sparse register bitmaps and all
> state combinations.  They check stale-dependence removal and producer
> order.
>
> On an aarch64 system, compiling gimple-match-6 is 47.5% faster at -O3.
> Generated assembly is unchanged.
> I've also confirmed that in all of SPEC2026 the assembly and scheduler
> dumps don't change, so this is supposed to be a purely compile-time
> improvement
>
> Bootstrapped and regtested on aarch64-none-linux-gnu and x86_64-linux.
>
> gcc/ChangeLog:
>
> 	* sched-int.h (struct deps_desc): Add pending_barriers.  Update the
> 	reg_last_dirty description.
> 	(deps_reg_last): Declare.
> 	* sched-deps.cc: Include selftest-rtl.h.
> 	(deps_reg_last): New.
> 	(sched_analyze_insn): Materialize pending barriers when required.
> 	Use the lazy barrier form before reload outside selective scheduling.
> 	Reconcile reg_last_dirty entries at barriers.
> 	(init_deps): Initialize pending_barriers.
> 	(free_deps): Release pending_barriers.
> 	(selftest::observed_barrier_deps): New.
> 	(selftest::observe_barrier_dependence): New.
> 	(selftest::assert_insn_list): New.
> 	(selftest::test_full_lazy_barrier): New.
> 	(selftest::test_sparse_lazy_barrier): New.
> 	(selftest::test_lazy_barrier_join): New.
> 	(selftest::test_lazy_barriers): New.
> 	(selftest::sched_deps_cc_tests): Run the lazy-barrier tests.
> 	* sched-rgn.cc (deps_join): Combine pending and materialized barrier
> 	state.
> 	* sel-sched-ir.cc (has_dependence_p): Assert that selective
> 	scheduling has no pending barriers.
>
> Signed-off-by: Kyrylo Tkachov <[email protected]>
OK.
jeff