https://gcc.gnu.org/g:82a9c3b4850be48ed1ed5cc471720a2445d50443
commit r17-5736-g82a9c3b4850be48ed1ed5cc471720a2445d50443 Author: Richard Biener <[email protected]> Date: Thu Oct 29 10:02:35 2026 +0100 tree-optimization/128277 - simple latches for CCP With CCP we really want less latch edges because those eventually trigger re-simulation of the header PHI separately, so initialize loops with LOOPS_HAVE_SIMPLE_LATCHES. This causes gcc.dg/tree-ssa/loop-25.c to regress because we now disambiguate earlier. PR tree-optimization/128277 * tree-ssa-ccp.cc (do_ssa_ccp): Initialize loops with LOOPS_HAVE_SIMPLE_LATCHES. * gcc.dg/tree-ssa/loop-25.c: Adjust. Diff: --- gcc/testsuite/gcc.dg/tree-ssa/loop-25.c | 4 ++-- gcc/tree-ssa-ccp.cc | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-25.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-25.c index 939ca8bfe266..a3e499eded4e 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/loop-25.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-25.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O1 -fdump-tree-profile_estimate" } */ +/* { dg-options "-O1 -fdump-tree-ccp1 -fdump-tree-profile_estimate" } */ int foo(void); void bla(void); @@ -118,7 +118,7 @@ void test5 (void) } } -/* { dg-final { scan-tree-dump-times "Disambiguating loop" 5 "profile_estimate" } } */ +/* { dg-final { scan-tree-dump-times "Disambiguating loop" 5 "ccp1" } } */ /* For the following xfail marks, see PR35629. */ /* { dg-final { scan-tree-dump-times "Found latch edge" 5 "profile_estimate" { xfail *-*-* } } } */ /* { dg-final { scan-tree-dump-times "Merged latch edges" 2 "profile_estimate" { xfail *-*-* } } } */ diff --git a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc index 9bd288db99cf..05162cc89f54 100644 --- a/gcc/tree-ssa-ccp.cc +++ b/gcc/tree-ssa-ccp.cc @@ -3049,6 +3049,10 @@ static unsigned int do_ssa_ccp (bool nonzero_p) { unsigned int todo = 0; + + /* We want to minimize the number of latches to reduce iteration. */ + loop_optimizer_init (LOOPS_HAVE_SIMPLE_LATCHES); + calculate_dominance_info (CDI_DOMINATORS); ccp_initialize (); @@ -3063,6 +3067,9 @@ do_ssa_ccp (bool nonzero_p) } free_dominance_info (CDI_DOMINATORS); + + loop_optimizer_finalize (); + return todo; }
