diff mbox

Remove dead code from fold_stmt_1

Message ID alpine.LNX.2.00.1211271259340.8142@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Nov. 27, 2012, noon UTC
This removes dead code as suggested by Jakub.

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

Richard.

2012-11-27  Richard Biener  <rguenther@suse.de>

	* gimple-fold.c (fold_stmt_1): Remove unnecessary code.

Comments

Jakub Jelinek Nov. 27, 2012, 12:07 p.m. UTC | #1
On Tue, Nov 27, 2012 at 01:00:05PM +0100, Richard Biener wrote:
> 
> This removes dead code as suggested by Jakub.
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu.

Looks as partial removal only.  IMHO
  gimple_stmt_iterator gsinext = *gsi;
  gimple next_stmt;

  gsi_next (&gsinext);
  next_stmt = gsi_end_p (gsinext) ? NULL : gsi_stmt (gsinext);
can go too and
  /* Fold *& on the lhs.  Don't do this if stmt folded into nothing,
     as we'd changing the next stmt.  */
  if (gimple_has_lhs (stmt) && stmt != next_stmt)
should be:
  /* Fold *& on the lhs.  */
  if (gimple_has_lhs (stmt))

> 2012-11-27  Richard Biener  <rguenther@suse.de>
> 
> 	* gimple-fold.c (fold_stmt_1): Remove unnecessary code.
> 
> Index: gcc/gimple-fold.c
> ===================================================================
> --- gcc/gimple-fold.c	(revision 193839)
> +++ gcc/gimple-fold.c	(working copy)
> @@ -1282,14 +1282,6 @@ fold_stmt_1 (gimple_stmt_iterator *gsi,
>      default:;
>      }
>  
> -  /* If stmt folds into nothing and it was the last stmt in a bb,
> -     don't call gsi_stmt.  */
> -  if (gsi_end_p (*gsi))
> -    {
> -      gcc_assert (next_stmt == NULL);
> -      return changed;
> -    }
> -
>    stmt = gsi_stmt (*gsi);
>  
>    /* Fold *& on the lhs.  Don't do this if stmt folded into nothing,

	Jakub
Richard Biener Dec. 6, 2012, 10:53 a.m. UTC | #2
On Tue, 27 Nov 2012, Jakub Jelinek wrote:

> On Tue, Nov 27, 2012 at 01:00:05PM +0100, Richard Biener wrote:
> > 
> > This removes dead code as suggested by Jakub.
> > 
> > Bootstrapped and tested on x86_64-unknown-linux-gnu.
> 
> Looks as partial removal only.  IMHO
>   gimple_stmt_iterator gsinext = *gsi;
>   gimple next_stmt;
> 
>   gsi_next (&gsinext);
>   next_stmt = gsi_end_p (gsinext) ? NULL : gsi_stmt (gsinext);
> can go too and
>   /* Fold *& on the lhs.  Don't do this if stmt folded into nothing,
>      as we'd changing the next stmt.  */
>   if (gimple_has_lhs (stmt) && stmt != next_stmt)
> should be:
>   /* Fold *& on the lhs.  */
>   if (gimple_has_lhs (stmt))

Indeed - the following removes that pieces as well.

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

Richard.

2012-12-06  Richard Biener  <rguenther@suse.de>

	* gimple-fold.c (fold_stmt_1): Remove code handling folding
	stmts away.

Index: gcc/gimple-fold.c
===================================================================
*** gcc/gimple-fold.c	(revision 194242)
--- gcc/gimple-fold.c	(working copy)
*************** fold_stmt_1 (gimple_stmt_iterator *gsi,
*** 1157,1167 ****
    bool changed = false;
    gimple stmt = gsi_stmt (*gsi);
    unsigned i;
-   gimple_stmt_iterator gsinext = *gsi;
-   gimple next_stmt;
- 
-   gsi_next (&gsinext);
-   next_stmt = gsi_end_p (gsinext) ? NULL : gsi_stmt (gsinext);
  
    /* Fold the main computation performed by the statement.  */
    switch (gimple_code (stmt))
--- 1157,1162 ----
*************** fold_stmt_1 (gimple_stmt_iterator *gsi,
*** 1284,1292 ****
  
    stmt = gsi_stmt (*gsi);
  
!   /* Fold *& on the lhs.  Don't do this if stmt folded into nothing,
!      as we'd changing the next stmt.  */
!   if (gimple_has_lhs (stmt) && stmt != next_stmt)
      {
        tree lhs = gimple_get_lhs (stmt);
        if (lhs && REFERENCE_CLASS_P (lhs))
--- 1279,1286 ----
  
    stmt = gsi_stmt (*gsi);
  
!   /* Fold *& on the lhs.  */
!   if (gimple_has_lhs (stmt))
      {
        tree lhs = gimple_get_lhs (stmt);
        if (lhs && REFERENCE_CLASS_P (lhs))
diff mbox

Patch

Index: gcc/gimple-fold.c
===================================================================
--- gcc/gimple-fold.c	(revision 193839)
+++ gcc/gimple-fold.c	(working copy)
@@ -1282,14 +1282,6 @@  fold_stmt_1 (gimple_stmt_iterator *gsi,
     default:;
     }
 
-  /* If stmt folds into nothing and it was the last stmt in a bb,
-     don't call gsi_stmt.  */
-  if (gsi_end_p (*gsi))
-    {
-      gcc_assert (next_stmt == NULL);
-      return changed;
-    }
-
   stmt = gsi_stmt (*gsi);
 
   /* Fold *& on the lhs.  Don't do this if stmt folded into nothing,