[tree-ssa] tree-ssa-dom fix

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Thu Aug 28 18:59:00 GMT 2003


Hello,

with jump threading it is no longer true that it makes no sense to
continue optimizing blocks with no predecessors.  Consider

# bb 0

if (x == y)
  # bb 1
  st1;
else
  # bb 2
  st2;

# bb 3
if (x == y)
  # bb 4
  st3;
else
  # bb 5
  st4;

#bb 6
a_lot_of_interesting_stuff

After threading the edges from bb 1 and 2 through 3, 3 has no
predecessors.  However, if we don't optimize it,
a_lot_of_interesting_stuff (that is reachable again) remains
unoptimized.

Zdenek

	* tree-ssa-dom.c (optimize_block): Optimize also unreachable
	blocks.

Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dom.c,v
retrieving revision 1.1.2.31
diff -c -3 -p -r1.1.2.31 tree-ssa-dom.c
*** tree-ssa-dom.c	25 Aug 2003 22:24:10 -0000	1.1.2.31
--- tree-ssa-dom.c	28 Aug 2003 18:54:40 -0000
*************** optimize_block (basic_block bb, tree par
*** 440,471 ****
  	    {
  	      basic_block dest = BASIC_BLOCK (i);
  
! 	      /* The destination block may have become unreachable, in
! 		 which case there's no point in optimizing it.  */
! 	      if (dest->pred)
! 		{
! 		  /* Ensure that we only take the condition into account
! 		     if there is no other way how to reach the target basic
! 		     block.  The fact that we have exactly one predecessor
! 		     also ensures that the predecessor is BB.  */
! 		  if (!dest->pred->pred_next)
! 		    optimize_block (dest, last, dest->pred->flags,
! 				    vars_to_rename);
! 		  else
! 		    optimize_block (dest, NULL_TREE, 0, vars_to_rename);
! 		}
  	    });
  	}
        else
  	{
! 	  EXECUTE_IF_SET_IN_BITMAP (children, 0, i,
  	    {
  	      basic_block dest = BASIC_BLOCK (i);
  
! 	      /* The destination block may have become unreachable, in
! 		 which case there's no point in optimizing it. */
! 	      if (dest->pred)
! 		optimize_block (dest, NULL_TREE, 0, vars_to_rename);
  	    });
  	}
      }
--- 440,463 ----
  	    {
  	      basic_block dest = BASIC_BLOCK (i);
  
! 	      /* Ensure that we only take the condition into account
! 		 if there is no other way how to reach the target basic
! 		 block.  The fact that we have exactly one predecessor
! 		 also ensures that the predecessor is BB.  */
! 	      if (dest->pred && !dest->pred->pred_next)
! 		optimize_block (dest, last, dest->pred->flags,
! 				vars_to_rename);
! 	      else
! 		optimize_block (dest, NULL_TREE, 0, vars_to_rename);
  	    });
  	}
        else
  	{
! 	  EXECUTE_IF_SET_IN_BITMAP (children, 0, i,);
  	    {
  	      basic_block dest = BASIC_BLOCK (i);
  
! 	      optimize_block (dest, NULL_TREE, 0, vars_to_rename);
  	    });
  	}
      }



More information about the Gcc-patches mailing list