This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix loop unrolling ICE (PR middle-end/39124)
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 10 Feb 2009 17:17:15 +0100
- Subject: Re: [PATCH] Fix loop unrolling ICE (PR middle-end/39124)
- References: <20090210153337.GN28939@tyan-ft48-01.lab.bos.redhat.com>
On Tue, Feb 10, 2009 at 4:33 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> During peeling if remove_path is called on a path completely containing some
> other loop GCC ICEs in get_loop_body called from cancel_loop. The problem
> is that remove_path first calls remove_bbs on all bbs we want to remove and
> only afterwards cancel_loop_tree to remove those loops. cancel_loop
> does:
> /* Move blocks up one level (they should be removed as soon as possible). */
> bbs = get_loop_body (loop);
> for (i = 0; i < loop->num_nodes; i++)
> bbs[i]->loop_father = outer;
> but get_loop_body ICEs when loop->num_nodes == 0 (as all the bbs have been
> removed previously). The following patch just swaps the order, first
> cancels loops and only afterwards removes the bbs, which I think matches the
> above mentioned comment and also matches what tree-loop-distribution.c
> does:
> cancel_loop_tree (loop);
>
> for (i = 0; i < nbbs; i++)
> delete_basic_block (bbs[i]);
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
Ok.
Thanks,
Richard.
> 2009-02-10 Jakub Jelinek <jakub@redhat.com>
>
> PR middle-end/39124
> * cfgloopmanip.c (remove_path): Call remove_bbs after
> cancel_loop_tree, not before it.
>
> --- gcc/cfgloopmanip.c.jj 2008-10-23 13:21:39.000000000 +0200
> +++ gcc/cfgloopmanip.c 2009-02-10 14:55:04.000000000 +0100
> @@ -1,5 +1,5 @@
> /* Loop manipulation code for GNU compiler.
> - Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008 Free Software
> + Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009 Free Software
> Foundation, Inc.
>
> This file is part of GCC.
> @@ -349,13 +349,13 @@ remove_path (edge e)
> if (rem_bbs[i]->loop_father->header == rem_bbs[i])
> deleted_loop[nreml++] = rem_bbs[i]->loop_father;
>
> - remove_bbs (rem_bbs, nrem);
> - free (rem_bbs);
> -
> for (i = 0; i < nreml; i++)
> cancel_loop_tree (deleted_loop[i]);
> free (deleted_loop);
>
> + remove_bbs (rem_bbs, nrem);
> + free (rem_bbs);
> +
> /* Find blocks whose dominators may be affected. */
> sbitmap_zero (seen);
> for (i = 0; i < n_bord_bbs; i++)
>
> Jakub
>