https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124405
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Pengxuan Zheng <[email protected]>: https://gcc.gnu.org/g:391ee229b737eb9a0cf3b705f41476f56d12d1e3 commit r17-1273-g391ee229b737eb9a0cf3b705f41476f56d12d1e3 Author: Pengxuan Zheng <[email protected]> Date: Wed Apr 8 18:09:48 2026 -0700 cselim: Allow middle_bb to have more than one statement [PR124405] Currently, cselim requires the middle_bb to have only a single statement. This patch relaxes this restriction as long as all uses (except the rhs) in the single stmatement are also available where we insert to. Bootstrapped and tested on x86_64-linux-gnu and aarch64-linux-gnu. Changes since v1: * v2: Revert changes to trailing_store_in_bb and do not call trailing_store_in_bb to get split_assign. Remove some unnecessary checks in cselim_candidate. Pass the result of cselim_candidate which is the candidate store for cselim as an argument to cond_store_replacement instead. * v3: Simplify cselim_candidate by always calling trailing_store_in_bb and removing the legality checks. Generalize the cond_store_replacement legality checks to account for the case when the middle_bb can have more than one statement. PR tree-optimization/124405 gcc/ChangeLog: * tree-ssa-phiopt.cc (cond_store_replacement): Make ASSIGN (the candidate store for cselim) an argument of the function instead. Update legality check due to relaxing the restriction that middle_bb can have only a single statement. (cselim_candidate): New. (pass_cselim::execute): Call cselim_candidate and pass the result to cond_store_replacement. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr124405.c: New test. Signed-off-by: Pengxuan Zheng <[email protected]>
