This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Minor speedup of var-tracking


Hello,

this patch changes the chained list operations not to use branch in loop.
The result is a nicer code and speedup of 10 seconds (of 82 minutes)
on GCC bootstrap on athlon.

Bootstrapped/regtested i686, x86-64, ia64.

Josef

2004-03-07  Josef Zlomek  <zlomekj@suse.cz>

	* var-tracking.c (vars_copy_1): Cleanup and speedup chain operations.
	(vars_copy): Likewise.
	(variable_union): Likewise.
	(set_variable_part): Likewise.
	(delete_variable_part): Likewise.

Index: var-tracking.c
===================================================================
RCS file: /cvs/gcc-cvs/gcc/gcc/var-tracking.c,v
retrieving revision 2.8
diff -c -p -c -3 -p -r2.8 var-tracking.c
*** var-tracking.c	4 Mar 2004 14:17:29 -0000	2.8
--- var-tracking.c	6 Mar 2004 09:23:32 -0000
*************** vars_copy_1 (void **slot, void *data)
*** 752,761 ****
  
    for (i = 0; i < var->n_var_parts; i++)
      {
!       location_chain last, node;
  
        var->var_part[i].offset = src->var_part[i].offset;
!       last = NULL;
        for (node = src->var_part[i].loc_chain; node; node = node->next)
  	{
  	  location_chain new_lc;
--- 752,762 ----
  
    for (i = 0; i < var->n_var_parts; i++)
      {
!       location_chain node;
!       location_chain *nextp;
  
        var->var_part[i].offset = src->var_part[i].offset;
!       nextp = &var->var_part[i].loc_chain;
        for (node = src->var_part[i].loc_chain; node; node = node->next)
  	{
  	  location_chain new_lc;
*************** vars_copy_1 (void **slot, void *data)
*** 764,774 ****
  	  new_lc->next = NULL;
  	  new_lc->loc = node->loc;
  
! 	  if (last)
! 	    last->next = new_lc;
! 	  else
! 	    var->var_part[i].loc_chain = new_lc;
! 	  last = new_lc;
  	}
  
        /* We are at the basic block boundary when copying variable description
--- 765,772 ----
  	  new_lc->next = NULL;
  	  new_lc->loc = node->loc;
  
! 	  *nextp = new_lc;
! 	  nextp = &new_lc->next;
  	}
  
        /* We are at the basic block boundary when copying variable description
*************** vars_copy (htab_t dst, htab_t src)
*** 798,830 ****
  static void
  var_reg_delete_and_set (dataflow_set *set, rtx loc)
  {
-   attrs *reg = &set->regs[REGNO (loc)];
    tree decl = REG_EXPR (loc);
    HOST_WIDE_INT offset = REG_OFFSET (loc);
!   attrs node, prev, next;
  
!   prev = NULL;
!   for (node = *reg; node; node = next)
      {
        next = node->next;
        if (node->decl != decl || node->offset != offset)
  	{
  	  delete_variable_part (set, node->loc, node->decl, node->offset);
- 
- 	  if (prev)
- 	    prev->next = next;
- 	  else
- 	    *reg = next;
  	  pool_free (attrs_pool, node);
  	}
        else
  	{
  	  node->loc = loc;
! 	  prev = node;
  	}
      }
!   if (*reg == NULL)
!     attrs_list_insert (reg, decl, offset, loc);
    set_variable_part (set, loc, decl, offset);
  }
  
--- 796,824 ----
  static void
  var_reg_delete_and_set (dataflow_set *set, rtx loc)
  {
    tree decl = REG_EXPR (loc);
    HOST_WIDE_INT offset = REG_OFFSET (loc);
!   attrs node, next;
!   attrs *nextp;
  
!   nextp = &set->regs[REGNO (loc)];
!   for (node = *nextp; node; node = next)
      {
        next = node->next;
        if (node->decl != decl || node->offset != offset)
  	{
  	  delete_variable_part (set, node->loc, node->decl, node->offset);
  	  pool_free (attrs_pool, node);
+ 	  *nextp = next;
  	}
        else
  	{
  	  node->loc = loc;
! 	  nextp = &node->next;
  	}
      }
!   if (set->regs[REGNO (loc)] == NULL)
!     attrs_list_insert (&set->regs[REGNO (loc)], decl, offset, loc);
    set_variable_part (set, loc, decl, offset);
  }
  
*************** variable_union (void **slot, void *data)
*** 1112,1120 ****
  		&& src->var_part[i].offset > dst->var_part[j].offset)
  	       || j < 0)
  	{
! 	  location_chain last = NULL;
  
  	  /* Copy the chain from SRC.  */
  	  for (node = src->var_part[i].loc_chain; node; node = node->next)
  	    {
  	      location_chain new_lc;
--- 1106,1115 ----
  		&& src->var_part[i].offset > dst->var_part[j].offset)
  	       || j < 0)
  	{
! 	  location_chain *nextp;
  
  	  /* Copy the chain from SRC.  */
+ 	  nextp = &dst->var_part[k].loc_chain;
  	  for (node = src->var_part[i].loc_chain; node; node = node->next)
  	    {
  	      location_chain new_lc;
*************** variable_union (void **slot, void *data)
*** 1123,1133 ****
  	      new_lc->next = NULL;
  	      new_lc->loc = node->loc;
  
! 	      if (last)
! 		last->next = new_lc;
! 	      else
! 		dst->var_part[k].loc_chain = new_lc;
! 	      last = new_lc;
  	    }
  
  	  dst->var_part[k].offset = src->var_part[i].offset;
--- 1118,1125 ----
  	      new_lc->next = NULL;
  	      new_lc->loc = node->loc;
  
! 	      *nextp = new_lc;
! 	      nextp = &new_lc->next;
  	    }
  
  	  dst->var_part[k].offset = src->var_part[i].offset;
*************** static void
*** 1863,1869 ****
  set_variable_part (dataflow_set *set, rtx loc, tree decl, HOST_WIDE_INT offset)
  {
    int pos, low, high;
!   location_chain node, prev, next;
    variable var;
    void **slot;
    
--- 1855,1862 ----
  set_variable_part (dataflow_set *set, rtx loc, tree decl, HOST_WIDE_INT offset)
  {
    int pos, low, high;
!   location_chain node, next;
!   location_chain *nextp;
    variable var;
    void **slot;
    
*************** set_variable_part (dataflow_set *set, rt
*** 1922,1928 ****
      }
  
    /* Delete the location from list.  */
!   prev = NULL;
    for (node = var->var_part[pos].loc_chain; node; node = next)
      {
        next = node->next;
--- 1915,1921 ----
      }
  
    /* Delete the location from list.  */
!   nextp = &var->var_part[pos].loc_chain;
    for (node = var->var_part[pos].loc_chain; node; node = next)
      {
        next = node->next;
*************** set_variable_part (dataflow_set *set, rt
*** 1930,1944 ****
  	   && REGNO (node->loc) == REGNO (loc))
  	  || rtx_equal_p (node->loc, loc))
  	{
- 	  if (prev)
- 	    prev->next = next;
- 	  else
- 	    var->var_part[pos].loc_chain = next;
  	  pool_free (loc_chain_pool, node);
  	  break;
  	}
        else
! 	prev = node;
      }
  
    /* Add the location to the beginning.  */
--- 1923,1934 ----
  	   && REGNO (node->loc) == REGNO (loc))
  	  || rtx_equal_p (node->loc, loc))
  	{
  	  pool_free (loc_chain_pool, node);
+ 	  *nextp = next;
  	  break;
  	}
        else
! 	nextp = &node->next;
      }
  
    /* Add the location to the beginning.  */
*************** delete_variable_part (dataflow_set *set,
*** 1987,2013 ****
  
        if (pos < var->n_var_parts && var->var_part[pos].offset == offset)
  	{
! 	  location_chain node, prev, next;
  	  bool changed;
  
  	  /* Delete the location part.  */
! 	  prev = NULL;
! 	  for (node = var->var_part[pos].loc_chain; node; node = next)
  	    {
  	      next = node->next;
  	      if ((GET_CODE (node->loc) == REG && GET_CODE (loc) == REG
  		   && REGNO (node->loc) == REGNO (loc))
  		  || rtx_equal_p (node->loc, loc))
  		{
- 		  if (prev)
- 		    prev->next = next;
- 		  else
- 		    var->var_part[pos].loc_chain = next;
  		  pool_free (loc_chain_pool, node);
  		  break;
  		}
  	      else
! 		prev = node;
  	    }
  
  	  /* If we have deleted the location which was last emitted
--- 1977,2001 ----
  
        if (pos < var->n_var_parts && var->var_part[pos].offset == offset)
  	{
! 	  location_chain node, next;
! 	  location_chain *nextp;
  	  bool changed;
  
  	  /* Delete the location part.  */
! 	  nextp = &var->var_part[pos].loc_chain;
! 	  for (node = *nextp; node; node = next)
  	    {
  	      next = node->next;
  	      if ((GET_CODE (node->loc) == REG && GET_CODE (loc) == REG
  		   && REGNO (node->loc) == REGNO (loc))
  		  || rtx_equal_p (node->loc, loc))
  		{
  		  pool_free (loc_chain_pool, node);
+ 		  *nextp = next;
  		  break;
  		}
  	      else
! 		nextp = &node->next;
  	    }
  
  	  /* If we have deleted the location which was last emitted


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]