From 0a1a3afb5fb36e2d10ad92bf788e16d837451571 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 14 Feb 2022 13:37:54 +0100 Subject: tree-optimization/104528 - free niter estimates after DSE When DSE removes a trivially dead def we have to reset niter information on loops since that might refer to it. The patch also adds verification to make sure this does not happen. 2022-02-14 Richard Biener PR tree-optimization/104528 * tree-ssa.h (find_released_ssa_name): Declare. * tree-ssa.cc (find_released_ssa_name): Export. * cfgloop.cc (verify_loop_structure): Look for released SSA names in loops nb_iterations. * tree-ssa-dse.cc (pass_dse::execute): Release number of iteration estimates. * gfortran.dg/pr104528.f: New testcase. --- gcc/cfgloop.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gcc/cfgloop.cc') diff --git a/gcc/cfgloop.cc b/gcc/cfgloop.cc index 78fd6d5..5ffcc77 100644 --- a/gcc/cfgloop.cc +++ b/gcc/cfgloop.cc @@ -31,6 +31,8 @@ along with GCC; see the file COPYING3. If not see #include "cfgloop.h" #include "gimple-iterator.h" #include "dumpfile.h" +#include "tree-ssa.h" +#include "tree-pretty-print.h" static void flow_loops_cfg_dump (FILE *); @@ -1561,6 +1563,17 @@ verify_loop_structure (void) err = 1; } } + + /* Check cached number of iterations for released SSA names. */ + tree ref; + if (loop->nb_iterations + && (ref = walk_tree (&loop->nb_iterations, + find_released_ssa_name, NULL, NULL))) + { + error ("loop %d%'s number of iterations %qE references the" + " released SSA name %qE", i, loop->nb_iterations, ref); + err = 1; + } } /* Check irreducible loops. */ -- cgit v1.1