This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Moving statements from one BB to other BB.
On Thu, Apr 17, 2008 at 1:35 PM, Sandeep Maram <sandeep244@gmail.com> wrote:
>
> On Tue, Apr 15, 2008 at 3:00 PM, Richard Guenther
> <richard.guenther@gmail.com> wrote:
> >
> > On Tue, Apr 15, 2008 at 7:49 AM, Sandeep Maram <sandeep244@gmail.com> wrote:
> > > On Tue, Apr 15, 2008 at 10:34 AM, Daniel Berlin <dberlin@dberlin.org> wrote:
> > > > To clarify what Richard means, your assertion that "you have updated
> > > > SSA information" is false.
> > > > If you had updated the SSA information, the error would not occur :).
> > > >
> > > > How exactly are you updating the ssa information?
> > >
> > > I am calling update_ssa (TODO_update_ssa), after all the statements
> > > are transferred.
> > >
> > >
> > > >
> > > > The general way to update SSA for this case would be:
> > > >
> > > > For each statement you have moved:
> > > > Call update_stmt (t);
> > > >
> > > > Then call update_ssa (TODO_update_ssa) (or instead use
> > > > rewrite_into_loop_closed_ssa if this is a loop pass).
> > > >
> > > > If you do not call update_stmt in this case, update_ssa won't actually
> > > > do anything.
> > > >
> > > > Diego, the bsi iterators do not update the statements for you though
> > > > it is not clear if this is a bug or not.
> > > >
> > > > The bsi iterators call update_modified_stmts, which says:
> > > >
> > > > /* Mark statement T as modified, and update it. */
> > > > static inline void
> > > > update_modified_stmts (tree t)
> > > >
> > > > However, this only calls update_stmt_if_modified (IE it does not mark
> > > > the statement as modified and update it, as it claims to).
> > > >
> > > > Sandeep, it should also suffice to call mark_stmt_modified *before*
> > > > moving the statements (since the above routine should then update
> > > > them).
> > > >
> > >
> > > Thanks. I will use update_stmt, update_ssa now.
> >
> > You need to do more than that - you appearantly are moving uses of
> > SSA names to a place where its definition is not available like if you do
> >
> > b_1 = 1;
> > a_1 = b_1 + 1;
> >
> > and transform this to
> >
> > a_1 = b_1 + 1;
> > b_1 = 1;
> >
> > which obviously cannot work. So "updating" SSA form won't help you
> > and renaming the symbols will only make the verifier happy and leave
> > you with wrong code.
> >
> > So you need to investigate what exactly you are doing wrong with
> > your stmt movement.
>
> I am considering two consequent fusible loops. These loops have a
> single header and a single latch. I want to move the statements in
> the header of the second loop to the header of the first loop. This
> function will be called only after certain constraints are met. That
> is legality test is performed before fusing these loops.
>
> I think I am transfering all the statements inside the loop correctly.
> But I am doing some mistake with the "iterator variable".
Well, we cannot do mind-reading here to figure out what exactly you
do wrong. Please have a look at the tree-dumps before and after
your transformation (-fdump-tree-all-vops), this should obviously
explain what is going wrong. I suppose you simply forgot about
PHI nodes.
Richard.