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]

Loop LUID accessor patch



This patch just tidies up accessing of the uid_luid array with a
couple of macros and is a stepping stone for the removal of this
array.

2000-12-29  Michael Hayes  <mhayes@redhat.com>

	* loop.c (REGNO_FIRST_LUID, REGNO_LAST_LUID): Define and
	use in place of direct access to uid_luid array.
	
*** loop.c.orig	Wed Dec 27 18:46:34 2000
--- loop.c	Wed Dec 27 22:10:14 2000
*************** Boston, MA 02111-1307, USA.  */
*** 54,59 ****
--- 54,63 ----
  #include "except.h"
  #include "toplev.h"
  
+ #define REGNO_FIRST_LUID(REGNO) uid_luid[REGNO_FIRST_UID (REGNO)]
+ #define REGNO_LAST_LUID(REGNO) uid_luid[REGNO_LAST_UID (REGNO)]
+ 
+ 
  /* Vector mapping INSN_UIDs to luids.
     The luids are like uids but increase monotonically always.
     We use them to see whether a jump comes from outside a given loop.  */
*************** scan_loop (loop, flags)
*** 829,840 ****
  		 or consec_sets_invariant_p returned 2
  		 (only conditionally invariant).  */
  	      m->cond = ((tem | tem1 | tem2) > 1);
! 	      m->global = (uid_luid[REGNO_LAST_UID (regno)]
  			   > INSN_LUID (loop_end)
! 			   || uid_luid[REGNO_FIRST_UID (regno)] < INSN_LUID (loop_start));
  	      m->match = 0;
! 	      m->lifetime = (uid_luid[REGNO_LAST_UID (regno)]
! 			     - uid_luid[REGNO_FIRST_UID (regno)]);
  	      m->savings = VARRAY_INT (regs->n_times_set, regno);
  	      if (find_reg_note (p, REG_RETVAL, NULL_RTX))
  		m->savings += libcall_benefit (p);
--- 833,844 ----
  		 or consec_sets_invariant_p returned 2
  		 (only conditionally invariant).  */
  	      m->cond = ((tem | tem1 | tem2) > 1);
! 	      m->global = (REGNO_LAST_LUID (regno)
  			   > INSN_LUID (loop_end)
! 			   || REGNO_FIRST_LUID (regno) < INSN_LUID (loop_start));
  	      m->match = 0;
! 	      m->lifetime = (REGNO_LAST_LUID (regno)
! 			     - REGNO_FIRST_LUID (regno));
  	      m->savings = VARRAY_INT (regs->n_times_set, regno);
  	      if (find_reg_note (p, REG_RETVAL, NULL_RTX))
  		m->savings += libcall_benefit (p);
*************** scan_loop (loop, flags)
*** 931,942 ****
  		     INSN_LUID and hence must make a conservative
  		     assumption.  */
  		  m->global = (INSN_UID (p) >= max_uid_for_loop
! 			       || (uid_luid[REGNO_LAST_UID (regno)]
  				   > INSN_LUID (loop_end))
! 			       || (uid_luid[REGNO_FIRST_UID (regno)]
  				   < INSN_LUID (p))
  			       || (labels_in_range_p
! 				   (p, uid_luid[REGNO_FIRST_UID (regno)])));
  		  if (maybe_never && m->global)
  		    m->savemode = GET_MODE (SET_SRC (set1));
  		  else
--- 935,946 ----
  		     INSN_LUID and hence must make a conservative
  		     assumption.  */
  		  m->global = (INSN_UID (p) >= max_uid_for_loop
! 			       || (REGNO_LAST_LUID (regno)
  				   > INSN_LUID (loop_end))
! 			       || (REGNO_FIRST_LUID (regno)
  				   < INSN_LUID (p))
  			       || (labels_in_range_p
! 				   (p, REGNO_FIRST_LUID (regno))));
  		  if (maybe_never && m->global)
  		    m->savemode = GET_MODE (SET_SRC (set1));
  		  else
*************** scan_loop (loop, flags)
*** 944,951 ****
  		  m->regno = regno;
  		  m->cond = 0;
  		  m->match = 0;
! 		  m->lifetime = (uid_luid[REGNO_LAST_UID (regno)]
! 				 - uid_luid[REGNO_FIRST_UID (regno)]);
  		  m->savings = 1;
  		  VARRAY_INT (regs->set_in_loop, regno) = -1;
  		  /* Add M to the end of the chain MOVABLES.  */
--- 948,955 ----
  		  m->regno = regno;
  		  m->cond = 0;
  		  m->match = 0;
! 		  m->lifetime = (REGNO_LAST_LUID (regno)
! 				 - REGNO_FIRST_LUID (regno));
  		  m->savings = 1;
  		  VARRAY_INT (regs->set_in_loop, regno) = -1;
  		  /* Add M to the end of the chain MOVABLES.  */
*************** combine_movables (movables, regs)
*** 1403,1410 ****
  	    && mode == GET_MODE (SET_SRC (PATTERN (NEXT_INSN (m->insn)))))
  	  {
  	    register struct movable *m1;
! 	    int first = uid_luid[REGNO_FIRST_UID (m->regno)];
! 	    int last = uid_luid[REGNO_LAST_UID (m->regno)];
  
  	    if (m0 == 0)
  	      {
--- 1407,1414 ----
  	    && mode == GET_MODE (SET_SRC (PATTERN (NEXT_INSN (m->insn)))))
  	  {
  	    register struct movable *m1;
! 	    int first = REGNO_FIRST_LUID (m->regno);
! 	    int last = REGNO_LAST_LUID (m->regno);
  
  	    if (m0 == 0)
  	      {
*************** combine_movables (movables, regs)
*** 1422,1429 ****
  	       already combined together.  */
  	    for (m1 = movables->head; m1 != m; m1 = m1->next)
  	      if (m1 == m0 || (m1->partial && m1->match == m0))
! 		if (! (uid_luid[REGNO_FIRST_UID (m1->regno)] > last
! 		       || uid_luid[REGNO_LAST_UID (m1->regno)] < first))
  		  goto overlap;
  
  	    /* No overlap: we can combine this with the others.  */
--- 1426,1433 ----
  	       already combined together.  */
  	    for (m1 = movables->head; m1 != m; m1 = m1->next)
  	      if (m1 == m0 || (m1->partial && m1->match == m0))
! 		if (! (REGNO_FIRST_LUID (m1->regno) > last
! 		       || REGNO_LAST_LUID (m1->regno) < first))
  		  goto overlap;
  
  	    /* No overlap: we can combine this with the others.  */
*************** move_movables (loop, movables, threshold
*** 2048,2059 ****
  		 to say it lives at least the full length of this loop.
  		 This will help guide optimizations in outer loops.  */
  
! 	      if (uid_luid[REGNO_FIRST_UID (regno)] > INSN_LUID (loop_start))
  		/* This is the old insn before all the moved insns.
  		   We can't use the moved insn because it is out of range
  		   in uid_luid.  Only the old insns have luids.  */
  		REGNO_FIRST_UID (regno) = INSN_UID (loop_start);
! 	      if (uid_luid[REGNO_LAST_UID (regno)] < INSN_LUID (loop_end))
  		REGNO_LAST_UID (regno) = INSN_UID (loop_end);
  
  	      /* Combine with this moved insn any other matching movables.  */
--- 2052,2063 ----
  		 to say it lives at least the full length of this loop.
  		 This will help guide optimizations in outer loops.  */
  
! 	      if (REGNO_FIRST_LUID (regno) > INSN_LUID (loop_start))
  		/* This is the old insn before all the moved insns.
  		   We can't use the moved insn because it is out of range
  		   in uid_luid.  Only the old insns have luids.  */
  		REGNO_FIRST_UID (regno) = INSN_UID (loop_start);
! 	      if (REGNO_LAST_LUID (regno) < INSN_LUID (loop_end))
  		REGNO_LAST_UID (regno) = INSN_UID (loop_end);
  
  	      /* Combine with this moved insn any other matching movables.  */
*************** strength_reduce (loop, insn_count, flags
*** 3858,3867 ****
  	 long as init_insn doesn't use the biv itself.
  	 March 14, 1989 -- self@bayes.arc.nasa.gov */
  
!       if ((uid_luid[REGNO_LAST_UID (bl->regno)] < INSN_LUID (loop_end)
  	   && bl->init_insn
  	   && INSN_UID (bl->init_insn) < max_uid_for_loop
! 	   && uid_luid[REGNO_FIRST_UID (bl->regno)] >= INSN_LUID (bl->init_insn)
  #ifdef HAVE_decrement_and_branch_until_zero
  	   && ! bl->nonneg
  #endif
--- 3862,3871 ----
  	 long as init_insn doesn't use the biv itself.
  	 March 14, 1989 -- self@bayes.arc.nasa.gov */
  
!       if ((REGNO_LAST_LUID (bl->regno) < INSN_LUID (loop_end)
  	   && bl->init_insn
  	   && INSN_UID (bl->init_insn) < max_uid_for_loop
! 	   && REGNO_FIRST_LUID (bl->regno) >= INSN_LUID (bl->init_insn)
  #ifdef HAVE_decrement_and_branch_until_zero
  	   && ! bl->nonneg
  #endif
*************** record_giv (loop, v, insn, src_reg, dest
*** 4917,4924 ****
      {
        v->mode = GET_MODE (SET_DEST (set));
  
!       v->lifetime = (uid_luid[REGNO_LAST_UID (REGNO (dest_reg))]
! 		     - uid_luid[REGNO_FIRST_UID (REGNO (dest_reg))]);
  
        /* If the lifetime is zero, it means that this register is
  	 really a dead store.  So mark this as a giv that can be
--- 4921,4928 ----
      {
        v->mode = GET_MODE (SET_DEST (set));
  
!       v->lifetime = (REGNO_LAST_LUID (REGNO (dest_reg))
! 		     - REGNO_FIRST_LUID (REGNO (dest_reg)));
  
        /* If the lifetime is zero, it means that this register is
  	 really a dead store.  So mark this as a giv that can be
*************** record_giv (loop, v, insn, src_reg, dest
*** 4963,4969 ****
  
        if (REGNO_FIRST_UID (REGNO (dest_reg)) == INSN_UID (insn)
  	  /* Previous line always fails if INSN was moved by loop opt.  */
! 	  && uid_luid[REGNO_LAST_UID (REGNO (dest_reg))]
  	  < INSN_LUID (loop->end)
  	  && (! not_every_iteration
  	      || last_use_this_basic_block (dest_reg, insn)))
--- 4967,4973 ----
  
        if (REGNO_FIRST_UID (REGNO (dest_reg)) == INSN_UID (insn)
  	  /* Previous line always fails if INSN was moved by loop opt.  */
! 	  && REGNO_LAST_LUID (REGNO (dest_reg))
  	  < INSN_LUID (loop->end)
  	  && (! not_every_iteration
  	      || last_use_this_basic_block (dest_reg, insn)))
*************** record_giv (loop, v, insn, src_reg, dest
*** 4986,4995 ****
  	  for (b = bl->biv; b; b = b->next_iv)
  	    {
  	      if (INSN_UID (b->insn) >= max_uid_for_loop
! 		  || ((uid_luid[INSN_UID (b->insn)]
! 		       >= uid_luid[REGNO_FIRST_UID (REGNO (dest_reg))])
! 		      && (uid_luid[INSN_UID (b->insn)]
! 			  <= uid_luid[REGNO_LAST_UID (REGNO (dest_reg))])))
  		{
  		  v->replaceable = 0;
  		  v->not_replaceable = 1;
--- 4990,4999 ----
  	  for (b = bl->biv; b; b = b->next_iv)
  	    {
  	      if (INSN_UID (b->insn) >= max_uid_for_loop
! 		  || ((INSN_LUID (b->insn)
! 		       >= REGNO_FIRST_LUID (REGNO (dest_reg)))
! 		      && (INSN_LUID (b->insn)
! 			  <= REGNO_LAST_LUID (REGNO (dest_reg)))))
  		{
  		  v->replaceable = 0;
  		  v->not_replaceable = 1;
*************** update_reg_last_use (x, insn)
*** 8205,8211 ****
       and hence this insn will never be the last use of x.  */
    if (GET_CODE (x) == REG && REGNO (x) < max_reg_before_loop
        && INSN_UID (insn) < max_uid_for_loop
!       && uid_luid[REGNO_LAST_UID (REGNO (x))] < uid_luid[INSN_UID (insn)])
      REGNO_LAST_UID (REGNO (x)) = INSN_UID (insn);
    else
      {
--- 8209,8215 ----
       and hence this insn will never be the last use of x.  */
    if (GET_CODE (x) == REG && REGNO (x) < max_reg_before_loop
        && INSN_UID (insn) < max_uid_for_loop
!       && REGNO_LAST_LUID (REGNO (x)) < INSN_LUID (insn))
      REGNO_LAST_UID (REGNO (x)) = INSN_UID (insn);
    else
      {

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