On Wed, Oct 28, 2026 at 7:16 AM Sendao Yan <[email protected]> wrote:
>
> The backward jump threader fails to thread the state-machine loop in
> binascii_a2b_base64 because the switch has already been lowered to a
> decision tree by the time the late FSM threading runs, and the
> duplication limits are tight for the resulting branch sequence.
>
> Lower the switch after the second pass_thread_jumps_full so the backward
> threader still sees the GIMPLE_SWITCH, but before pass_dominator so the
> lowered decision tree is cleaned up by the following jump threading.
> pass_dominator and pass_strlen keep their places and the non-FSM
> pass_thread_jumps moves after them, restoring the GCC 11 performance
> (PR128102) without introducing a -Wmaybe-uninitialized false positive.
>
> The reordering also removes a pre-existing false positive in
> uninit-pred-7_a.c.
LGTM (I assume bootstrapped and tested on a primary arch).
Thanks,
Richard.
> gcc/
> * passes.def (pass_lower_switch): Move after the second
> pass_thread_jumps_full and before pass_dominator.
> (pass_thread_jumps_full): Move before pass_dominator.
> (pass_thread_jumps): Move after pass_strlen.
>
> gcc/testsuite/
> * gcc.dg/uninit-pred-7_a.c: Remove the xfail on the bogus warning
> in foo() now fixed by the pass reordering.
> ---
> gcc/passes.def | 9 ++++++---
> gcc/testsuite/gcc.dg/uninit-pred-7_a.c | 2 +-
> 2 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/passes.def b/gcc/passes.def
> index 9095c134f49..1b1d96d1668 100644
> --- a/gcc/passes.def
> +++ b/gcc/passes.def
> @@ -346,7 +346,6 @@ along with GCC; see the file COPYING3. If not see
> POP_INSERT_PASSES ()
> NEXT_PASS (pass_simduid_cleanup);
> NEXT_PASS (pass_lower_vector_ssa);
> - NEXT_PASS (pass_lower_switch);
> NEXT_PASS (pass_cse_sincos);
> NEXT_PASS (pass_cse_reciprocals);
> NEXT_PASS (pass_reassoc, false /* early_p */);
> @@ -355,10 +354,14 @@ along with GCC; see the file COPYING3. If not see
> NEXT_PASS (pass_fre, false /* may_iterate */);
> /* After late FRE we rewrite no longer addressed locals into SSA
> form if possible. */
> - NEXT_PASS (pass_thread_jumps, /*first=*/false);
> + /* Lower switches after the FSM threading so the backward threader
> + still sees the GIMPLE_SWITCH, but before DOM so the lowered
> + decision tree is cleaned up by the following jump threading. */
> + NEXT_PASS (pass_thread_jumps_full, /*first=*/false);
> + NEXT_PASS (pass_lower_switch);
> NEXT_PASS (pass_dominator, false /* may_peel_loop_headers_p */);
> NEXT_PASS (pass_strlen);
> - NEXT_PASS (pass_thread_jumps_full, /*first=*/false);
> + NEXT_PASS (pass_thread_jumps, /*first=*/false);
> NEXT_PASS (pass_vrp, true /* final_p */);
> /* Run CCP to compute alignment and nonzero bits. */
> NEXT_PASS (pass_ccp, true /* nonzero_p */);
> diff --git a/gcc/testsuite/gcc.dg/uninit-pred-7_a.c
> b/gcc/testsuite/gcc.dg/uninit-pred-7_a.c
> index 5dd92176c8f..f1fcb364a0d 100644
> --- a/gcc/testsuite/gcc.dg/uninit-pred-7_a.c
> +++ b/gcc/testsuite/gcc.dg/uninit-pred-7_a.c
> @@ -19,7 +19,7 @@ int foo (int n, int l, int m, int r)
> blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */
>
> if ( n )
> - blah(v); /* { dg-bogus "uninitialized" "bogus warning" { xfail *-*-* }
> } */
> + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */
>
> if ( l )
> blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */
> --
> 2.34.1
>