This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] for PR 24226
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 9 Oct 2005 17:47:15 +0200
- Subject: [patch] for PR 24226
Hello,
this PR works the following way:
1) a part of cfg containing a loop L becomes unreachable and is
removed by cfg cleanup. The loop L is marked for removal in
fix_loop_structure. The information about # of
iterations of L contains some ssa name X that was
defined in the removed blocks and hence X was released.
2) Still in cfg cleanup (before fix_loop_structure is called),
basic block merging removes some phi node. To do so, it calls
replace_uses_by (OLD, NEW), that also attempts to update # of information
records. This causes OLD to be searched within # of information for
L, and compared with X. Since X was released, its type is NULL,
thus causing ICE in operand_equal_p.
This patch fixes the problem by releasing # of iterations information
in the moment loop is detected to be unreachable.
Bootstrapped & regtested on i686.
Zdenek
PR tree-optimization/24226
* tree-cfg.c (remove_bb): Clean up unreachable loops.
* tree-flow.h (free_numbers_of_iterations_estimates_loop): Declare.
* tree-ssa-loop-niter.c (free_numbers_of_iterations_estimates_loop):
Export.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.222
diff -c -3 -p -r2.222 tree-cfg.c
*** tree-cfg.c 6 Oct 2005 00:02:57 -0000 2.222
--- tree-cfg.c 9 Oct 2005 09:01:27 -0000
*************** remove_bb (basic_block bb)
*** 2020,2025 ****
--- 2020,2031 ----
{
loop->latch = NULL;
loop->header = NULL;
+
+ /* Also clean up the information associated with the loop. Updating
+ it would waste time. More importantly, it may refer to ssa
+ names that were defined in other removed basic block -- these
+ ssa names are now removed and invalid. */
+ free_numbers_of_iterations_estimates_loop (loop);
}
}
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-flow.h,v
retrieving revision 2.137
diff -c -3 -p -r2.137 tree-flow.h
*** tree-flow.h 6 Oct 2005 00:02:57 -0000 2.137
--- tree-flow.h 9 Oct 2005 09:01:27 -0000
*************** bool scev_probably_wraps_p (tree, tree,
*** 735,740 ****
--- 735,741 ----
bool *);
tree convert_step (struct loop *, tree, tree, tree, tree);
void free_numbers_of_iterations_estimates (struct loops *);
+ void free_numbers_of_iterations_estimates_loop (struct loop *);
void rewrite_into_loop_closed_ssa (bitmap, unsigned);
void verify_loop_closed_ssa (void);
void loop_commit_inserts (void);
Index: tree-ssa-loop-niter.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-niter.c,v
retrieving revision 2.45
diff -c -3 -p -r2.45 tree-ssa-loop-niter.c
*** tree-ssa-loop-niter.c 27 Sep 2005 15:33:51 -0000 2.45
--- tree-ssa-loop-niter.c 9 Oct 2005 09:01:27 -0000
*************** convert_step (struct loop *loop, tree ne
*** 2007,2017 ****
/* Frees the information on upper bounds on numbers of iterations of LOOP. */
! static void
free_numbers_of_iterations_estimates_loop (struct loop *loop)
{
struct nb_iter_bound *bound, *next;
!
for (bound = loop->bounds; bound; bound = next)
{
next = bound->next;
--- 2007,2019 ----
/* Frees the information on upper bounds on numbers of iterations of LOOP. */
! void
free_numbers_of_iterations_estimates_loop (struct loop *loop)
{
struct nb_iter_bound *bound, *next;
!
! loop->nb_iterations = NULL;
! loop->estimated_nb_iterations = NULL;
for (bound = loop->bounds; bound; bound = next)
{
next = bound->next;