This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Operator Strength Reduction on trees


Hello,

> > +/* Return the last non-control statement in a basic block, or NULL if
> > +   there is none.  */
> > +
> > +static tree
> > +last_nonjump_stmt (basic_block block)
> > +{
> > +  block_stmt_iterator last = bsi_last (block);
> > +  tree stmt;
> > +
> > +  if (bsi_end_p (last))
> > +    return NULL_TREE;
> > +  stmt = bsi_stmt (last);
> > +
> > +  while (stmt_ends_bb_p (stmt))
> > +    {
> > +      bsi_prev (&last);
> > +      if (bsi_end_p (last))
> > +	return NULL_TREE;
> > +      stmt = bsi_stmt (last);
> > +    }
> > +  return stmt; /* bsi_stmt (last); */
> > +}
> > 
> > Was there ever a statement that was not bsi_last, which did end the
> > basic block? Seems to me that this means the block should have been
> > split.  In other words, I don't believe you need the while loop
> > here.
> 
> Is the while loop expensive? I don't see how two ifs (one to check,
> one to assert that the while loop isn't needed) would be better.

the loop obviously is not needed, you do not need to assert that
(and even if you do, the assert is removed from non-checking compiler,
so it does not count).

Zdenek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]