https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122193
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <[email protected]>: https://gcc.gnu.org/g:cf64e6b0e07355043d26a9d17ad749aa42b1aa9b commit r17-1705-gcf64e6b0e07355043d26a9d17ad749aa42b1aa9b Author: Andrew Pinski <[email protected]> Date: Wed Jun 17 16:09:40 2026 -0700 phiopt: Add support for non-zero offsets for load factoring [PR122193] This extends the factor_out_conditional_load to support non-zero offsets for the MEM_REF. And fixes PR 122193. It tries not to create gimple statements that don't need to be created. E.g. If the base is the same then it creates the pointer plus in the join bb rather than the in the middle bbs. Also uses gimple_build for the pointer plus so that the if one of the offsets was 0, a new statement is not created. Bootstrapped and tested on x86_64-linux-gnu. PR tree-optimization/122193 gcc/ChangeLog: * tree-ssa-phiopt.cc (factor_out_conditional_load): Support non-zero offsets. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/factor_op_phi-load-offsets-1.c: New test. * gcc.dg/tree-ssa/factor_op_phi-load-offsets-2.c: New test. * gcc.dg/tree-ssa/factor_op_phi-load-offsets-3.c: New test. Signed-off-by: Andrew Pinski <[email protected]>
