diff mbox

Make sure cfg-cleanup runs

Message ID alpine.LSU.2.11.1406180952390.29270@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener June 18, 2014, 7:53 a.m. UTC
This makes sure we run cfg-cleanup when we propagate into PHI nodes
or on the FRE/PRE side remove any stmt.  Otherwise we can end up
with not removed forwarder blocks.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2014-06-18  Richard Biener  <rguenther@suse.de>

	* tree-ssa-propagate.c (replace_phi_args_in): Return whether
	we propagated anything.
	(substitute_and_fold_dom_walker::before_dom_children): Something
	changed if we propagated into PHI arguments.
	* tree-ssa-pre.c (eliminate): Always schedule cfg-cleanup if
	we removed a stmt.
diff mbox

Patch

Index: gcc/tree-ssa-propagate.c
===================================================================
--- gcc/tree-ssa-propagate.c	(revision 211738)
+++ gcc/tree-ssa-propagate.c	(working copy)
@@ -964,7 +964,7 @@  replace_uses_in (gimple stmt, ssa_prop_g
 /* Replace propagated values into all the arguments for PHI using the
    values from PROP_VALUE.  */
 
-static void
+static bool
 replace_phi_args_in (gimple phi, ssa_prop_get_value_fn get_value)
 {
   size_t i;
@@ -1015,6 +1015,8 @@  replace_phi_args_in (gimple phi, ssa_pro
 	  fprintf (dump_file, "\n");
 	}
     }
+
+  return replaced;
 }
 
 
@@ -1066,7 +1068,7 @@  substitute_and_fold_dom_walker::before_d
 	      continue;
 	    }
 	}
-      replace_phi_args_in (phi, get_value_fn);
+      something_changed |= replace_phi_args_in (phi, get_value_fn);
     }
 
   /* Propagate known values into stmts.  In some case it exposes
Index: gcc/tree-ssa-pre.c
===================================================================
--- gcc/tree-ssa-pre.c	(revision 211738)
+++ gcc/tree-ssa-pre.c	(working copy)
@@ -4521,11 +4521,7 @@  eliminate (bool do_pre)
 
       gsi = gsi_for_stmt (stmt);
       if (gimple_code (stmt) == GIMPLE_PHI)
-	{
-	  remove_phi_node (&gsi, true);
-	  /* Removing a PHI node in a block may expose a forwarder block.  */
-	  el_todo |= TODO_cleanup_cfg;
-	}
+	remove_phi_node (&gsi, true);
       else
 	{
 	  basic_block bb = gimple_bb (stmt);
@@ -4534,6 +4530,9 @@  eliminate (bool do_pre)
 	    bitmap_set_bit (need_eh_cleanup, bb->index);
 	  release_defs (stmt);
 	}
+
+      /* Removing a stmt may expose a forwarder block.  */
+      el_todo |= TODO_cleanup_cfg;
     }
   el_to_remove.release ();