https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127246
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Kyrylo Tkachov <[email protected]>: https://gcc.gnu.org/g:028b8b62979f7e6326cb15ec8e519b1600e86a36 commit r17-4922-g028b8b62979f7e6326cb15ec8e519b1600e86a36 Author: Kyrylo Tkachov <[email protected]> Date: Fri Sep 11 16:31:01 2026 +0200 cfgcleanup: keep tail merging out of an unfactored computed goto [PR127246] bbcb0c056be (PR15242) stopped try_crossjump_bb from sharing the tails of the predecessors of a computed jump unless optimizing for size. pass_duplicate_computed_gotos copies the jump back into each predecessor and a shared tail defeats that. efd8f7507b3 replaced !optimize_size with optimize_bb_for_size_p (bb), which inverted the test: tails are now shared in code optimized for speed and kept apart in code optimized for size. Test the condition of the gate of pass_duplicate_computed_gotos instead, !optimize_function_for_size_p (cfun) && flag_expensive_optimizations. PR42621 fixed the bb-reorder half of the same change in that gate. As in bbcb0c056be, the guard then applies to the whole function, also to a block that is too large to be unfactored. try_head_merge_bb has a copy of the inverted test that cannot change code, because every successor edge of a computed jump is abnormal. It stays as it is. On the PR127246 testcase with identical handler tails and -fno-tree-slp-vectorize, jump2 no longer crossjumps the handlers at -O2 only for compgotos to copy the tails back. With BB SLP the handlers jump to a block of vector copies in front of the dispatch, which is a separate problem of the PR. At -Os the handler tails are shared again, which makes the aarch64 code of the PR testcase 54% smaller. With -fno-expensive-optimizations, which disables the duplication, the tails are shared as well. Bootstrapped and regression tested on aarch64-unknown-linux-gnu and x86_64-pc-linux-gnu. gcc/ChangeLog: PR rtl-optimization/127246 * cfgcleanup.cc (try_crossjump_bb): Keep the predecessors of a computed jump apart under the condition of the gate of pass_duplicate_computed_gotos. gcc/testsuite/ChangeLog: PR rtl-optimization/127246 * gcc.dg/pr127246-1.c: New test. * gcc.dg/pr127246-2.c: New test. * gcc.dg/pr127246-3.c: New test. Signed-off-by: Kyrylo Tkachov <[email protected]>
