This is the mail archive of the gcc-bugs@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]

[Bug rtl-optimization/33828] Issues with the implementation of code hoisting in gcse.c



------- Comment #3 from steven at gcc dot gnu dot org  2007-10-20 10:54 -------
There is a discrepancy between the code in gcse.c:hoist_expr_reaches_here_p()
and the comment before it.  Quoting:

/* Determine if the expression identified by EXPR_INDEX would
   reach BB unimpared if it was placed at the end of EXPR_BB.

   It's unclear exactly what Muchnick meant by "unimpared".  It seems
   to me that the expression must either be computed or transparent in
   *every* block in the path(s) from EXPR_BB to BB.  Any other definition
   would allow the expression to be hoisted out of loops, even if
   the expression wasn't a loop invariant.

   Contrast this to reachability for PRE where an expression is
   considered reachable if *any* path reaches instead of *all*
   paths.  */

static int
hoist_expr_reaches_here_p (basic_block expr_bb, int expr_index, basic_block bb,
char *visited)
{
  ...

      /* Does this predecessor generate this expression?  */
      else if (TEST_BIT (comp[pred_bb->index], expr_index))
        break;
      else if (! TEST_BIT (transp[pred_bb->index], expr_index))
        break;

  ...

The comment says that the expression is hoistable if pred_bb computes the
expression identified by EXPR_INDEX.  But the code makes the function return
false if a basic block on the path from EXPR_BB to BB computes this expression.

It seems to me that the comment is right, and the code needs fixing.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33828


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