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.
Lowering the switch later, after the second pass_thread_jumps_full,
keeps the GIMPLE_SWITCH available to the backward threader so the loop
body can be replicated and the '=' test left on the hot path, restoring
the GCC 11 performance (PR128102).
The reorder exposes a latent limitation of the uninit analysis at -O1,
where no range-propagating pass remains after the late lowering to fold
away the unreachable default branch of a nested switch, causing a
-Wmaybe-uninitialized false positive (gcc.dg/uninit-pr44547.c). The
next patch teaches the uninit analysis to prove such edges infeasible.
gcc/
* passes.def (pass_lower_switch): Move after the second
pass_thread_jumps_full.
---
gcc/passes.def | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/passes.def b/gcc/passes.def
index 9095c134f49..69c5a4f0808 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 */);
@@ -359,6 +358,7 @@ along with GCC; see the file COPYING3. If not see
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_lower_switch);
NEXT_PASS (pass_vrp, true /* final_p */);
/* Run CCP to compute alignment and nonzero bits. */
NEXT_PASS (pass_ccp, true /* nonzero_p */);
--
2.34.1