Hi!

When working on clobber sinking, I've noticed that
optimize_clobbers would mistakenly remove just one clobber
instead of all consecutive ones, because gsi_remove moves
the iterator to the next rather than previous stmt (i.e.
GIMPLE_RESX if no debug stmts) and we return in the next iteration.

Fixed thusly, and with a small cleanup to use gimple_clobber_p
predicate too.  Bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?

2011-12-09  Jakub Jelinek  <ja...@redhat.com>

        PR tree-optimization/51117
        * tree-eh.c (optimize_clobbers): Don't remove just one
        clobber, but all consecutive clobbers before RESX.
        Use gimple_clobber_p predicate.

--- gcc/tree-eh.c.jj    2011-12-09 13:08:11.000000000 +0100
+++ gcc/tree-eh.c       2011-12-09 15:13:51.849968215 +0100
@@ -3180,17 +3180,13 @@ static void
 optimize_clobbers (basic_block bb)
 {
   gimple_stmt_iterator gsi = gsi_last_bb (bb);
-  for (gsi_prev (&gsi); !gsi_end_p (gsi);)
+  for (gsi_prev (&gsi); !gsi_end_p (gsi); gsi_prev (&gsi))
     {
       gimple stmt = gsi_stmt (gsi);
       if (is_gimple_debug (stmt))
-       {
-         gsi_prev (&gsi);
-         continue;
-       }
-      if (!gimple_assign_single_p (stmt)
-         || TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME
-         || !TREE_CLOBBER_P (gimple_assign_rhs1 (stmt)))
+       continue;
+      if (!gimple_clobber_p (stmt)
+         || TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME)
        return;
       unlink_stmt_vdef (stmt);
       gsi_remove (&gsi, true);

        Jakub

Reply via email to