Small DOM record_equivalences_from_incoming_edge speedup

Steven Bosscher stevenb@suse.de
Thu May 27 00:23:00 GMT 2004


Hi Jeff, all,

In record_equivalences_from_incoming_edge, we try to record the
condition of a switch by looking at the value of case labels that
transfer control to the basic block under consideration.

We identify such case labels by looking if one or more cases jump
from the idom block to the head of the current basic block, so
there seems to be an implicit assumption that the idom block is
the only predecessor of the current block.  But we do not test for
that fact.  With the attached patch, we do.
This gives a small speedup for code such as that of PR15524.

Furthermore, there is no need to look for other case labels if the
first one we see is already a range.  This happens quite often if
you have my case label grouping patch applied.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
OK if it passes?

Gr.
Steven


	* tree-ssa-dom.c (record_equivalences_from_incoming_edge):
	Only look at case labels if the immediate dominator is also
	the only predecessor.  Don't look for more case labels if the
	first seen is a case range.

Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-dom.c,v
retrieving revision 2.5
diff -c -3 -p -r2.5 tree-ssa-dom.c
*** tree-ssa-dom.c	18 May 2004 02:53:55 -0000	2.5
--- tree-ssa-dom.c	26 May 2004 21:01:59 -0000
*************** record_equivalences_from_incoming_edge (
*** 1450,1458 ****
  				       &bd->avail_exprs,
  				       bb,
  				       &bd->vrp_variables);
!   /* Similarly when the parent block ended in a SWITCH_EXPR.  */
    else if (parent_block_last_stmt
  	   && bb->pred->pred_next == NULL
  	   && TREE_CODE (parent_block_last_stmt) == SWITCH_EXPR)
      {
        tree switch_cond = SWITCH_COND (parent_block_last_stmt);
--- 1450,1461 ----
  				       &bd->avail_exprs,
  				       bb,
  				       &bd->vrp_variables);
!   /* Similarly when the parent block ended in a SWITCH_EXPR.
!      We can only know the value of the switch's condition if the dominator
!      parent is also the only predecessor of this block.  */
    else if (parent_block_last_stmt
  	   && bb->pred->pred_next == NULL
+ 	   && bb->pred->src == parent
  	   && TREE_CODE (parent_block_last_stmt) == SWITCH_EXPR)
      {
        tree switch_cond = SWITCH_COND (parent_block_last_stmt);
*************** record_equivalences_from_incoming_edge (
*** 1473,1479 ****
  	      tree elt = TREE_VEC_ELT (switch_vec, i);
  	      if (label_to_block (CASE_LABEL (elt)) == bb)
  		{
! 		  if (++case_count > 1)
  		    break;
  		  match_case = elt;
  		}
--- 1476,1482 ----
  	      tree elt = TREE_VEC_ELT (switch_vec, i);
  	      if (label_to_block (CASE_LABEL (elt)) == bb)
  		{
! 		  if (++case_count > 1 || CASE_HIGH (elt))
  		    break;
  		  match_case = elt;
  		}
*************** record_equivalences_from_incoming_edge (
*** 1484,1489 ****
--- 1487,1493 ----
  	     the exact value of SWITCH_COND which caused us to get to
  	     this block.  Record that equivalence in EQ_EXPR_VALUE.  */
  	  if (case_count == 1
+ 	      && match_case
  	      && CASE_LOW (match_case)
  	      && !CASE_HIGH (match_case))
  	    {



More information about the Gcc-patches mailing list