On 9/16/26 1:29 PM, Andrea Pinski wrote:
On Wed, Sep 16, 2026 at 10:57 AM Andrea Pinski <[email protected]> wrote:Currently we reject most commonalization of loads in factor_out_conditional_load before the vectorizer. This was done as the easiest and simpliest herustics at the time I was writing the code. We can do better than that. This inproves the heurstics by allowing pointers which don't analyize via scalar evolution. This means loads which are from other loads can be factored out earlier than the loop optimizers. This changes 2 testcases which are now factored out in phiopt2 and one testcase where we don't want the factoring out before the vectorizer as we want to be able to vectorize the code (derived from eembc's telecom/viterb00data_1 benchmark). Bootstrapped and tested on x86_64-linux-gnu. PR tree-optimization/125945 gcc/ChangeLog: * tree-ssa-phiopt.cc (induction_based): New function. (factor_out_conditional_load): Allow some factoring out with early and/or before_vect. (factor_out_all): Set before_vect to false when not vectorizing. (pass_phiopt::execute): Initialize scev in some cases. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/scc-diamond-1.c: * gcc.dg/tree-ssa/scc-diamond-3.c: * gcc.dg/tree-ssa/factor_op_phi-load-vect-1.c: New test.Just a small change to the changelog that I missed about the testsuite: * gcc.dg/tree-ssa/scc-diamond-1.c: Update to look at phiopt2 rather than phiopt4. * gcc.dg/tree-ssa/scc-diamond-3.c: Likewise.
OK jeff
