This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Fusing two loops
Hi Zdenek,
Thanks.
Sandeep.
On Thu, Apr 10, 2008 at 7:29 PM, Zdenek Dvorak <rakdver@kam.mff.cuni.cz> wrote:
> Hi,
>
> > The error is rectified. The bug is in the function that calls fuse_loops().
> > Now I am trying to transfer all the statements, using code -
> >
> > /* The following function fuses two loops. */
> >
> > void
> > fuse_loops (struct loop *loop_a, struct loop *loop_b)
> > {
> > debug_loop (loop_a, 10);
> > debug_loop (loop_b, 10);
> > block_stmt_iterator bsi_a = bsi_start (loop_a->header);
> > block_stmt_iterator bsi_a_last = bsi_last (loop_a->header);
> > block_stmt_iterator bsi_b = bsi_last (loop_b->header);
> > while (&bsi_a != &bsi_a_last)
> > {
> > bsi_move_before (&bsi_a, &bsi_b);
> > fprintf (stderr, " transferred one statement from loop %d to
> > loop %d ", loop_a->num, loop_b->num);
> > bsi_next (&bsi_a);
> > }
>
> try
>
>
> bsi_b = bsi_last (loop_b->header);
>
> for (bsi_a = bsi_start (loop_a->header); !bsi_end_p (bsi_a); )
> {
> if (some condition) /* you probably want to skip labels and cond_exprs */
>
> bsi_move_before (&bsi_a, &bsi_b);
> else
> bsi_next (&bsi_a);
> }
>
> Zdenek
>