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: ra-rewrite.c comment fixes


The comments in ra-rewrite.c were difficult to read, so
I removed a bunch of extraneous commas and reformatted
some of the more prepositionally difficult ones.

Toshi

2003-08-14  Toshiyasu Morita  <toshiyasu.morita@renesas.com>

	* ra-rewrite.c: Comment fixes.

*** ra-rewrite.c.orig	Thu Aug 14 15:14:22 2003
--- ra-rewrite.c	Thu Aug 14 16:10:56 2003
***************
*** 37,43 ****
  #include "reload.h"
  
  /* This file is part of the graph coloring register allocator, and
!    contains the functions to change the insn stream.  I.e. it adds
     spill code, rewrites insns to use the new registers after
     coloring and deletes coalesced moves.  */
  
--- 37,43 ----
  #include "reload.h"
  
  /* This file is part of the graph coloring register allocator, and
!    contains the functions to change the insn stream; i.e. it adds
     spill code, rewrites insns to use the new registers after
     coloring and deletes coalesced moves.  */
  
*************** static unsigned HOST_WIDE_INT deleted_mo
*** 79,86 ****
  
  /* This is the spill coalescing phase.  In SPILLED the IDs of all
     already spilled webs are noted.  In COALESCED the IDs of webs still
!    to check for coalescing.  This tries to coalesce two webs, which were
!    spilled, are connected by a move, and don't conflict.  Greatly
     reduces memory shuffling.  */
  
  static void
--- 79,86 ----
  
  /* This is the spill coalescing phase.  In SPILLED the IDs of all
     already spilled webs are noted.  In COALESCED the IDs of webs still
!    to check for coalescing.  This tries to coalesce two web which were
!    spilled, are connected by a move, and don't conflict.  This greatly
     reduces memory shuffling.  */
  
  static void
*************** spill_coalescing (coalesce, spilled)
*** 111,121 ****
  
  	    m->target_web->target_of_spilled_move = 1;
  	    if (s == t)
! 	      /* May be, already coalesced due to a former move.  */
  	      continue;
  	    /* Merge the nodes S and T in the I-graph.  Beware: the merging
! 	       of conflicts relies on the fact, that in the conflict list
! 	       of T all of it's conflicts are noted.  This is currently not
  	       the case if T would be the target of a coalesced web, because
  	       then (in combine () above) only those conflicts were noted in
  	       T from the web which was coalesced into T, which at the time
--- 111,121 ----
  
  	    m->target_web->target_of_spilled_move = 1;
  	    if (s == t)
! 	      /* May be already coalesced due to a former move.  */
  	      continue;
  	    /* Merge the nodes S and T in the I-graph.  Beware: the merging
! 	       of conflicts relies on the fact that in the conflict list
! 	       of T all of its conflicts are noted.  This is currently not
  	       the case if T would be the target of a coalesced web, because
  	       then (in combine () above) only those conflicts were noted in
  	       T from the web which was coalesced into T, which at the time
*************** spill_prop_savings (web, spilled)
*** 192,198 ****
    return savings;
  }
  
! /* This add all IDs of colored webs, which are connected to WEB by a move
     to LIST and PROCESSED.  */
  
  static void
--- 192,198 ----
    return savings;
  }
  
! /* This adds all IDs of colored webs which are connected to WEB by a move
     to LIST and PROCESSED.  */
  
  static void
*************** spill_prop_insert (web, list, processed)
*** 220,230 ****
        }
  }
  
! /* The spill propagation pass.  If we have to spilled webs, the first
     connected through a move to a colored one, and the second also connected
     to that colored one, and this colored web is only used to connect both
     spilled webs, it might be worthwhile to spill that colored one.
!    This is the case, if the cost of the removed copy insns (all three webs
     could be placed into the same stack slot) is higher than the spill cost
     of the web.
     TO_PROP are the webs we try to propagate from (i.e. spilled ones),
--- 220,230 ----
        }
  }
  
! /* The spill propagation pass.  If we have two spilled webs, the first
     connected through a move to a colored one, and the second also connected
     to that colored one, and this colored web is only used to connect both
     spilled webs, it might be worthwhile to spill that colored one.
!    This is the case if the cost of the removed copy insns (all three webs
     could be placed into the same stack slot) is higher than the spill cost
     of the web.
     TO_PROP are the webs we try to propagate from (i.e. spilled ones),
*************** spill_propagation (to_prop, spilled, pro
*** 247,253 ****
      });
    sbitmap_zero (to_prop);
  
!   /* For all candidates, see, if the savings are higher than it's
       spill cost.  */
    while ((id = sbitmap_first_set_bit (list)) >= 0)
      {
--- 247,253 ----
      });
    sbitmap_zero (to_prop);
  
!   /* For all candidates, see if the savings are higher than its
       spill cost.  */
    while ((id = sbitmap_first_set_bit (list)) >= 0)
      {
*************** spill_propagation (to_prop, spilled, pro
*** 255,262 ****
        RESET_BIT (list, id);
        if (spill_prop_savings (web, spilled) >= web->spill_cost)
  	{
! 	  /* If so, we found a new spilled web.  Insert it's colored
! 	     move neighbors again, and mark, that we need to repeat the
  	     whole mainloop of spillprog/coalescing again.  */
  	  remove_web_from_list (web);
  	  web->color = -1;
--- 255,262 ----
        RESET_BIT (list, id);
        if (spill_prop_savings (web, spilled) >= web->spill_cost)
  	{
! 	  /* If so, we found a new spilled web.  Insert its colored
! 	     move neighbors again and mark that we need to repeat the
  	     whole mainloop of spillprog/coalescing again.  */
  	  remove_web_from_list (web);
  	  web->color = -1;
*************** spill_coalprop ()
*** 292,298 ****
      {
        spill_coalescing (to_prop, spilled);
        /* XXX Currently (with optimistic coalescing) spill_propagation()
! 	 doesn't give better code, sometimes it gives worse (but not by much)
  	 code.  I believe this is because of slightly wrong cost
  	 measurements.  Anyway right now it isn't worth the time it takes,
  	 so deactivate it for now.  */
--- 292,298 ----
      {
        spill_coalescing (to_prop, spilled);
        /* XXX Currently (with optimistic coalescing) spill_propagation()
! 	 doesn't give better code; sometimes it gives worse (but not by much)
  	 code.  I believe this is because of slightly wrong cost
  	 measurements.  Anyway right now it isn't worth the time it takes,
  	 so deactivate it for now.  */
*************** spill_coalprop ()
*** 307,313 ****
  /* Allocate a spill slot for a WEB.  Currently we spill to pseudo
     registers, to be able to track also webs for "stack slots", and also
     to possibly colorize them.  These pseudos are sometimes handled
!    in a special way, where we know, that they also can represent
     MEM references.  */
  
  static void
--- 307,313 ----
  /* Allocate a spill slot for a WEB.  Currently we spill to pseudo
     registers, to be able to track also webs for "stack slots", and also
     to possibly colorize them.  These pseudos are sometimes handled
!    in a special way where we know that they also can represent
     MEM references.  */
  
  static void
*************** static unsigned HOST_WIDE_INT spill_load
*** 383,389 ****
  static unsigned HOST_WIDE_INT spill_store_cost;
  static unsigned HOST_WIDE_INT spill_remat_cost;
  
! /* In rewrite_program2() we detect if some def us useless, in the sense,
     that the pseudo set is not live anymore at that point.  The REF_IDs
     of such defs are noted here.  */
  static bitmap useless_defs;
--- 383,389 ----
  static unsigned HOST_WIDE_INT spill_store_cost;
  static unsigned HOST_WIDE_INT spill_remat_cost;
  
! /* In rewrite_program2() we detect if some def us useless in the sense
     that the pseudo set is not live anymore at that point.  The REF_IDs
     of such defs are noted here.  */
  static bitmap useless_defs;
*************** rewrite_program (new_deaths)
*** 404,411 ****
    struct dlist *d;
    bitmap b = BITMAP_XMALLOC ();
  
!   /* We walk over all webs, over all uses/defs.  For all webs, we need
!      to look at spilled webs, and webs coalesced to spilled ones, in case
       their alias isn't broken up, or they got spill coalesced.  */
    for (i = 0; i < 2; i++)
      for (d = (i == 0) ? WEBS(SPILLED) : WEBS(COALESCED); d; d = d->next)
--- 404,411 ----
    struct dlist *d;
    bitmap b = BITMAP_XMALLOC ();
  
!   /* We walk over all webs - over all uses/defs.  For all webs, we need
!      to look at spilled webs and webs coalesced to spilled ones, in case
       their alias isn't broken up, or they got spill coalesced.  */
    for (i = 0; i < 2; i++)
      for (d = (i == 0) ? WEBS(SPILLED) : WEBS(COALESCED); d; d = d->next)
*************** rewrite_program (new_deaths)
*** 436,442 ****
  		  continue;
  
  		/* Check that we didn't already added a load for this web
! 		   and insn.  Happens, when the an insn uses the same web
  		   multiple times.  */
  	        if (bitmap_bit_p (b, INSN_UID (insn)))
  		  continue;
--- 436,442 ----
  		  continue;
  
  		/* Check that we didn't already added a load for this web
! 		   and insn.  This happens when the an insn uses the same web
  		   multiple times.  */
  	        if (bitmap_bit_p (b, INSN_UID (insn)))
  		  continue;
*************** rewrite_program (new_deaths)
*** 468,474 ****
  	  }
  
  	/* Now emit the stores after each def.
! 	   If any uses were loaded from stackslots (compared to
  	   rematerialized or not reloaded due to IR spilling),
  	   aweb->stack_slot will be set.  If not, we don't need to emit
  	   any stack stores.  */
--- 468,474 ----
  	  }
  
  	/* Now emit the stores after each def.
! 	   If any uses were loaded from stack slots (compared to
  	   rematerialized or not reloaded due to IR spilling),
  	   aweb->stack_slot will be set.  If not, we don't need to emit
  	   any stack stores.  */
*************** rewrite_program (new_deaths)
*** 515,521 ****
  	      spill_store_cost += bb->frequency + 1;
  	      /* XXX we should set new_deaths for all inserted stores
  		 whose pseudo dies here.
! 		 Note, that this isn't the case for _all_ stores.  */
  	      /* I.e. the next is wrong, and might cause some spilltemps
  		 to be categorized as spilltemp2's (i.e. live over a death),
  		 although they aren't.  This might make them spill again,
--- 515,521 ----
  	      spill_store_cost += bb->frequency + 1;
  	      /* XXX we should set new_deaths for all inserted stores
  		 whose pseudo dies here.
! 		 Note that this isn't the case for _all_ stores.  */
  	      /* I.e. the next is wrong, and might cause some spilltemps
  		 to be categorized as spilltemp2's (i.e. live over a death),
  		 although they aren't.  This might make them spill again,
*************** remember_slot (list, x)
*** 550,558 ****
    *list = l;
  }
  
! /* Given two rtx' S1 and S2, either being REGs or MEMs (or SUBREGs
!    thereof), return nonzero, if they overlap.  REGs and MEMs don't
!    overlap, and if they are MEMs they must have an easy address
     (plus (basereg) (const_inst x)), otherwise they overlap.  */
  
  static int
--- 550,558 ----
    *list = l;
  }
  
! /* Given two RTXs S1 and S2, either being REGs or MEMs (or SUBREGs
!    thereof), return nonzero if they overlap.  REGs and MEMs don't
!    overlap, and if they are MEMs they must have an simple address
     (plus (basereg) (const_inst x)), otherwise they overlap.  */
  
  static int
*************** slots_overlap_p (s1, s2)
*** 603,610 ****
    return 1;
  }
  
! /* This deletes from *LIST all rtx's which overlap with X in the sense
!    of slots_overlap_p().  */
  
  static void
  delete_overlapping_slots (list, x)
--- 603,610 ----
    return 1;
  }
  
! /* This deletes all RTXs (which overlap with X in the sense
!    of slots_overlap_p() from *LIST.  */
  
  static void
  delete_overlapping_slots (list, x)
*************** delete_overlapping_slots (list, x)
*** 620,626 ****
      }
  }
  
! /* Returns nonzero, of X is member of LIST.  */
  
  static int
  slot_member_p (list, x)
--- 620,626 ----
      }
  }
  
! /* Returns nonzero if X is member of LIST.  */
  
  static int
  slot_member_p (list, x)
*************** slot_member_p (list, x)
*** 633,640 ****
    return 0;
  }
  
! /* A more sophisticated (and slower) method of adding the stores, than
!    rewrite_program().  This goes backward the insn stream, adding
     stores as it goes, but only if it hasn't just added a store to the
     same location.  NEW_DEATHS is a bitmap filled with uids of insns
     containing deaths.  */
--- 633,640 ----
    return 0;
  }
  
! /* A more sophisticated (and slower) method of adding the stores than
!    rewrite_program().  This scans backward throughthe insn stream, adding
     stores as it goes, but only if it hasn't just added a store to the
     same location.  NEW_DEATHS is a bitmap filled with uids of insns
     containing deaths.  */
*************** insert_stores (new_deaths)
*** 647,658 ****
    rtx last_slot = NULL_RTX;
    struct rtx_list *slots = NULL;
  
!   /* We go simply backwards over basic block borders.  */
    for (insn = get_last_insn (); insn; insn = PREV_INSN (insn))
      {
        int uid = INSN_UID (insn);
  
!       /* If we reach a basic block border, which has more than one
  	 outgoing edge, we simply forget all already emitted stores.  */
        if (GET_CODE (insn) == BARRIER
  	  || JUMP_P (insn) || can_throw_internal (insn))
--- 647,658 ----
    rtx last_slot = NULL_RTX;
    struct rtx_list *slots = NULL;
  
!   /* We scan backwards over basic block borders.  */
    for (insn = get_last_insn (); insn; insn = PREV_INSN (insn))
      {
        int uid = INSN_UID (insn);
  
!       /* If we reach a basic block border which has more than one
  	 outgoing edge, we simply forget all already emitted stores.  */
        if (GET_CODE (insn) == BARRIER
  	  || JUMP_P (insn) || can_throw_internal (insn))
*************** insert_stores (new_deaths)
*** 725,740 ****
  	}
        /* If we look at a load generated by the allocator, forget
  	 the last emitted slot, and additionally clear all slots
! 	 overlapping it's source (after all, we need it again).  */
        /* XXX If we emit the stack-ref directly into the using insn the
           following needs a change, because that is no new insn.  Preferably
! 	 we would add some notes to the insn, what stackslots are needed
  	 for it.  */
        if (uid >= last_max_uid)
  	{
  	  rtx set = single_set (insn);
  	  last_slot = NULL_RTX;
! 	  /* If this was no simple set, give up, and forget everything.  */
  	  if (!set)
  	    slots = NULL;
  	  else
--- 725,740 ----
  	}
        /* If we look at a load generated by the allocator, forget
  	 the last emitted slot, and additionally clear all slots
! 	 overlapping its source (after all, we need it again).  */
        /* XXX If we emit the stack-ref directly into the using insn the
           following needs a change, because that is no new insn.  Preferably
! 	 we would add some notes to the insn, what stack slots are needed
  	 for it.  */
        if (uid >= last_max_uid)
  	{
  	  rtx set = single_set (insn);
  	  last_slot = NULL_RTX;
! 	  /* If this was not a simple set, give up and forget everything.  */
  	  if (!set)
  	    slots = NULL;
  	  else
*************** insert_stores (new_deaths)
*** 746,752 ****
      }
  }
  
! /* Returns 1 if both colored webs have some hardregs in common, even if
     they are not the same width.  */
  
  static int
--- 746,752 ----
      }
  }
  
! /* Returns 1 if both colored webs have some hard regs in common, even if
     they are not the same width.  */
  
  static int
*************** spill_same_color_p (web1, web2)
*** 768,774 ****
    return 1;
  }
  
! /* Given the set of live web IDs LIVE, returns nonzero, if any of WEBs
     subwebs (or WEB itself) is live.  */
  
  static bool
--- 768,774 ----
    return 1;
  }
  
! /* Given the set of live web IDs LIVE, return nonzero if any of WEBs
     subwebs (or WEB itself) is live.  */
  
  static bool
*************** update_spill_colors (in_use, web, add)
*** 821,828 ****
  
  /* Given a set of hardregs currently IN_USE and the color C of WEB,
     return -1 if WEB has no color, 1 of it has the unusable color,
!    0 if one of it's used hardregs are in use, and 1 otherwise.
!    Generally, if WEB can't be left colorized return 1.  */
  
  static int
  spill_is_free (in_use, web)
--- 821,828 ----
  
  /* Given a set of hardregs currently IN_USE and the color C of WEB,
     return -1 if WEB has no color, 1 of it has the unusable color,
!    0 if one of its used hardregs are in use, and 1 otherwise.
!    Otherwise, if WEB can't be left colorized return 1.  */
  
  static int
  spill_is_free (in_use, web)
*************** spill_is_free (in_use, web)
*** 847,853 ****
  struct rewrite_info
  {
    /* The web IDs which currently would need a reload.  These are
!      currently live spilled webs, whose color was still free.  */
    bitmap need_reload;
    /* We need a scratch bitmap, but don't want to allocate one a zillion
       times.  */
--- 847,853 ----
  struct rewrite_info
  {
    /* The web IDs which currently would need a reload.  These are
!      currently live spilled webs whose color was still free.  */
    bitmap need_reload;
    /* We need a scratch bitmap, but don't want to allocate one a zillion
       times.  */
*************** struct rewrite_info
*** 856,862 ****
       not just those of the superwebs.  If only on part is live, only
       that ID is placed here.  */
    sbitmap live;
!   /* An array of webs, which currently need a load added.
       They will be emitted when seeing the first death.  */ 
    struct web **needed_loads;
    /* The current number of entries in needed_loads.  */
--- 856,862 ----
       not just those of the superwebs.  If only on part is live, only
       that ID is placed here.  */
    sbitmap live;
!   /* An array of webs which currently need a load added.
       They will be emitted when seeing the first death.  */ 
    struct web **needed_loads;
    /* The current number of entries in needed_loads.  */
*************** struct rewrite_info
*** 865,882 ****
    int num_reloads;
    /* The current set of hardregs not available.  */
    HARD_REG_SET colors_in_use;
!   /* Nonzero, if we just added some spill temps to need_reload or
       needed_loads.  In this case we don't wait for the next death
       to emit their loads.  */
    int any_spilltemps_spilled;
!   /* Nonzero, if we currently need to emit the loads.  E.g. when we
       saw an insn containing deaths.  */
    int need_load;
  };
  
  /* The needed_loads list of RI contains some webs for which
     we add the actual load insns here.  They are added just before
!    their use last seen.  NL_FIRST_RELOAD is the index of the first
     load which is a converted reload, all other entries are normal
     loads.  LAST_BLOCK_INSN is the last insn of the current basic block.  */
  
--- 865,882 ----
    int num_reloads;
    /* The current set of hardregs not available.  */
    HARD_REG_SET colors_in_use;
!   /* Nonzero if we just added some spill temps to need_reload or
       needed_loads.  In this case we don't wait for the next death
       to emit their loads.  */
    int any_spilltemps_spilled;
!   /* Nonzero if we currently need to emit the loads.  E.g. when we
       saw an insn containing deaths.  */
    int need_load;
  };
  
  /* The needed_loads list of RI contains some webs for which
     we add the actual load insns here.  They are added just before
!    their last use seen.  NL_FIRST_RELOAD is the index of the first
     load which is a converted reload, all other entries are normal
     loads.  LAST_BLOCK_INSN is the last insn of the current basic block.  */
  
*************** emit_loads (ri, nl_first_reload, last_bl
*** 895,911 ****
        rtx ni, slot, reg;
        rtx before = NULL_RTX, after = NULL_RTX;
        basic_block bb;
!       /* When spilltemps were spilled for the last insns, their
! 	 loads already are emitted, which is noted by setting
  	 needed_loads[] for it to 0.  */
        if (!web)
  	continue;
        supweb = find_web_for_subweb (web);
        if (supweb->regno >= max_normal_pseudo)
  	abort ();
!       /* Check for web being a spilltemp, if we only want to
! 	 load spilltemps.  Also remember, that we emitted that
! 	 load, which we don't need to do when we have a death,
  	 because then all of needed_loads[] is emptied.  */
        if (!ri->need_load)
  	{
--- 895,911 ----
        rtx ni, slot, reg;
        rtx before = NULL_RTX, after = NULL_RTX;
        basic_block bb;
!       /* When spill temps were spilled for the last insns, their
! 	 loads already are emitted which is noted by setting
  	 needed_loads[] for it to 0.  */
        if (!web)
  	continue;
        supweb = find_web_for_subweb (web);
        if (supweb->regno >= max_normal_pseudo)
  	abort ();
!       /* Check for web being a spill temp if we only want to
! 	 load spill temps.  Also remember that we emitted that
! 	 load which we don't need to do when we have a death,
  	 because then all of needed_loads[] is emptied.  */
        if (!ri->need_load)
  	{
*************** emit_loads (ri, nl_first_reload, last_bl
*** 927,933 ****
  	     we must also disallow coalescing _to_ rematerialized webs
  	     (at least then disallow spilling them, which we already ensure
  	     when flag_ra_break_aliases), or not take the pattern but a
! 	     stackslot.  */
  	  if (aweb != supweb)
  	    abort ();
  	  slot = copy_rtx (supweb->pattern);
--- 927,933 ----
  	     we must also disallow coalescing _to_ rematerialized webs
  	     (at least then disallow spilling them, which we already ensure
  	     when flag_ra_break_aliases), or not take the pattern but a
! 	     stack slot.  */
  	  if (aweb != supweb)
  	    abort ();
  	  slot = copy_rtx (supweb->pattern);
*************** emit_loads (ri, nl_first_reload, last_bl
*** 1001,1007 ****
  	  spill_load_cost += bb->frequency + 1;
  	}
        RESET_BIT (ri->live, web->id);
!       /* In the special case documented above only emit the reloads and
  	 one load.  */
        if (ri->need_load == 2 && j < nl_first_reload)
  	break;
--- 1001,1007 ----
  	  spill_load_cost += bb->frequency + 1;
  	}
        RESET_BIT (ri->live, web->id);
!       /* In the special case documented above, only emit the reloads and
  	 one load.  */
        if (ri->need_load == 2 && j < nl_first_reload)
  	break;
*************** emit_loads (ri, nl_first_reload, last_bl
*** 1014,1020 ****
     uses or defs) in REFS, and REF2WEB to translate ref IDs to webs
     (either use2web or def2web) convert some reloads to loads.
     This looks at the webs referenced, and how they change the set of
!    available colors.  Now put all still live webs, which needed reloads,
     and whose colors isn't free anymore, on the needed_loads list.  */
  
  static void
--- 1014,1020 ----
     uses or defs) in REFS, and REF2WEB to translate ref IDs to webs
     (either use2web or def2web) convert some reloads to loads.
     This looks at the webs referenced, and how they change the set of
!    available colors.  Now put all still live webs which needed reloads,
     and whose colors isn't free anymore, on the needed_loads list.  */
  
  static void
*************** reloads_to_loads (ri, refs, num_refs, re
*** 1034,1047 ****
        int j;
        /* Only emit reloads when entering their interference
  	 region.  A use of a spilled web never opens an
! 	 interference region, independent of it's color.  */
        if (alias (supweb)->type == SPILLED)
  	continue;
        if (supweb->type == PRECOLORED
  	  && TEST_HARD_REG_BIT (never_use_colors, supweb->color))
  	continue;
!       /* Note, that if web (and supweb) are DEFs, we already cleared
! 	 the corresponding bits in live.  I.e. is_death becomes true, which
  	 is what we want.  */
        is_death = !TEST_BIT (ri->live, supweb->id);
        is_death &= !TEST_BIT (ri->live, web->id);
--- 1034,1047 ----
        int j;
        /* Only emit reloads when entering their interference
  	 region.  A use of a spilled web never opens an
! 	 interference region, independent of its color.  */
        if (alias (supweb)->type == SPILLED)
  	continue;
        if (supweb->type == PRECOLORED
  	  && TEST_HARD_REG_BIT (never_use_colors, supweb->color))
  	continue;
!       /* Note that if web (and supweb) are DEFs, we already cleared
! 	 the corresponding bits in live, i.e. is_death becomes true, which
  	 is what we want.  */
        is_death = !TEST_BIT (ri->live, supweb->id);
        is_death &= !TEST_BIT (ri->live, web->id);
*************** reloads_to_loads (ri, refs, num_refs, re
*** 1077,1083 ****
  
  /* This adds loads for spilled webs to the program.  It uses a kind of
     interference region spilling.  If flag_ra_ir_spilling is zero it
!    only uses improved chaitin spilling (adding loads only at insns
     containing deaths).  */
  
  static void
--- 1077,1083 ----
  
  /* This adds loads for spilled webs to the program.  It uses a kind of
     interference region spilling.  If flag_ra_ir_spilling is zero it
!    only uses improved Chaitin spilling (adding loads only at insns
     containing deaths).  */
  
  static void
*************** rewrite_program2 (new_deaths)
*** 1114,1126 ****
  	{
  	  struct web *web = use2web[j];
  	  struct web *aweb = alias (find_web_for_subweb (web));
! 	  /* A web is only live at end, if it isn't spilled.  If we wouldn't
  	     check this, the last uses of spilled web per basic block
! 	     wouldn't be detected as deaths, although they are in the final
! 	     code.  This would lead to cumulating many loads without need,
! 	     only increasing register pressure.  */
! 	  /* XXX do add also spilled webs which got a color for IR spilling.
! 	     Remember to not add to colors_in_use in that case.  */
  	  if (aweb->type != SPILLED /*|| aweb->color >= 0*/)
  	    {
  	      SET_BIT (ri.live, web->id);
--- 1114,1126 ----
  	{
  	  struct web *web = use2web[j];
  	  struct web *aweb = alias (find_web_for_subweb (web));
! 	  /* A web is only live at end if it isn't spilled.  If we didn't
  	     check this, the last uses of spilled web per basic block
! 	     wouldn't be detected as deaths although they are in the final
! 	     code.  This would lead to cumulating many loads unnecessarily
! 	     which only increases register pressure.  */
! 	  /* XXX also add spilled webs which received a color for IR spilling.
! 	     Remember not to add to colors_in_use in that case.  */
  	  if (aweb->type != SPILLED /*|| aweb->color >= 0*/)
  	    {
  	      SET_BIT (ri.live, web->id);
*************** rewrite_program2 (new_deaths)
*** 1216,1224 ****
  		supweb = find_web_for_subweb (web);
  		/* Webs which are defined here, but also used in the same insn
  		   are rmw webs, or this use isn't a death because of looping
! 		   constructs.  In neither case makes this def available it's
! 		   resources.  Reloads for it are still needed, it's still
! 		   live and it's colors don't become free.  */
  		for (n2 = 0; n2 < info.num_uses; n2++)
  		  {
  		    struct web *web2 = use2web[DF_REF_ID (info.uses[n2])];
--- 1216,1224 ----
  		supweb = find_web_for_subweb (web);
  		/* Webs which are defined here, but also used in the same insn
  		   are rmw webs, or this use isn't a death because of looping
! 		   constructs.  In neither case makes this def available its
! 		   resources.  Reloads for it are still needed; it's still
! 		   live and its colors don't become free.  */
  		for (n2 = 0; n2 < info.num_uses; n2++)
  		  {
  		    struct web *web2 = use2web[DF_REF_ID (info.uses[n2])];
*************** rewrite_program2 (new_deaths)
*** 1278,1285 ****
  	  nl_first_reload = ri.nl_size;
  
  	  /* CALL_INSNs are not really deaths, but still more registers
! 	     are free after a call, than before.
! 	     XXX Note, that sometimes reload barfs when we emit insns between
  	     a call and the insn which copies the return register into a
  	     pseudo.  */
  	  if (GET_CODE (insn) == CALL_INSN)
--- 1278,1285 ----
  	  nl_first_reload = ri.nl_size;
  
  	  /* CALL_INSNs are not really deaths, but still more registers
! 	     are free after a call than before.
! 	     XXX Note that sometimes reload barfs when we emit insns between
  	     a call and the insn which copies the return register into a
  	     pseudo.  */
  	  if (GET_CODE (insn) == CALL_INSN)
*************** rewrite_program2 (new_deaths)
*** 1308,1318 ****
                int old_num_reloads = ri.num_reloads;
  	      reloads_to_loads (&ri, info.uses, info.num_uses, use2web);
  
! 	      /* If this insn sets a pseudo, which isn't used later
! 		 (i.e. wasn't live before) it is a dead store.  We need
  		 to emit all reloads which have the same color as this def.
  		 We don't need to check for non-liveness here to detect
! 		 the deadness (it anyway is too late, as we already cleared
  		 the liveness in the first loop over the defs), because if it
  		 _would_ be live here, no reload could have that color, as
  		 they would already have been converted to a load.  */
--- 1308,1318 ----
                int old_num_reloads = ri.num_reloads;
  	      reloads_to_loads (&ri, info.uses, info.num_uses, use2web);
  
! 	      /* If this insn sets a pseudo which isn't used later
! 		 (i.e. wasn't live before) then it is a dead store.  We need
  		 to emit all reloads which have the same color as this def.
  		 We don't need to check for non-liveness here to detect
! 		 the deadness (it ss too late anyway, as we already cleared
  		 the liveness in the first loop over the defs), because if it
  		 _would_ be live here, no reload could have that color, as
  		 they would already have been converted to a load.  */
*************** rewrite_program2 (new_deaths)
*** 1438,1447 ****
  }
  
  /* WEBS is a web conflicting with a spilled one.  Prepare it
!    to be able to rescan it in the next pass.  Mark all it's uses
     for checking, and clear the some members of their web parts
     (of defs and uses).  Notably don't clear the uplink.  We don't
!    change the layout of this web, just it's conflicts.
     Also remember all IDs of its uses in USES_AS_BITMAP.  */
  
  static void
--- 1438,1447 ----
  }
  
  /* WEBS is a web conflicting with a spilled one.  Prepare it
!    to be able to rescan it in the next pass.  Mark all its uses
     for checking, and clear the some members of their web parts
     (of defs and uses).  Notably don't clear the uplink.  We don't
!    change the layout of this web, just its conflicts.
     Also remember all IDs of its uses in USES_AS_BITMAP.  */
  
  static void
*************** mark_refs_for_checking (web, uses_as_bit
*** 1470,1476 ****
     incrementally rebuilding the interference graph.  We break up
     the web part structure of all spilled webs, mark their uses for
     rechecking, look at their neighbors, and clean up some global
!    information, we will rebuild.  */
  
  static void
  detect_web_parts_to_rebuild ()
--- 1470,1476 ----
     incrementally rebuilding the interference graph.  We break up
     the web part structure of all spilled webs, mark their uses for
     rechecking, look at their neighbors, and clean up some global
!    information which we will rebuild.  */
  
  static void
  detect_web_parts_to_rebuild ()
*************** detect_web_parts_to_rebuild ()
*** 1488,1494 ****
    sbitmap_zero (already_webs);
    /* We need to recheck all uses of all webs involved in spilling (and the
       uses added by spill insns, but those are not analyzed yet).
!      Those are the spilled webs themselves, webs coalesced to spilled ones,
       and webs conflicting with any of them.  */
    for (pass = 0; pass < 2; pass++)
      for (d = (pass == 0) ? WEBS(SPILLED) : WEBS(COALESCED); d; d = d->next)
--- 1488,1494 ----
    sbitmap_zero (already_webs);
    /* We need to recheck all uses of all webs involved in spilling (and the
       uses added by spill insns, but those are not analyzed yet).
!      Those are: the spilled webs themselves, webs coalesced to spilled ones,
       and webs conflicting with any of them.  */
    for (pass = 0; pass < 2; pass++)
      for (d = (pass == 0) ? WEBS(SPILLED) : WEBS(COALESCED); d; d = d->next)
*************** detect_web_parts_to_rebuild ()
*** 1500,1507 ****
  	if (alias (web)->type != SPILLED)
  	  continue;
  
! 	/* For the spilled web itself we also need to clear it's
! 	   uplink, to be able to rebuild smaller webs.  After all
  	   spilling has split the web.  */
          for (i = 0; i < web->num_uses; i++)
  	  {
--- 1500,1507 ----
  	if (alias (web)->type != SPILLED)
  	  continue;
  
! 	/* For the spilled web itself we also need to clear its
! 	   uplink to be able to rebuild smaller webs after all
  	   spilling has split the web.  */
          for (i = 0; i < web->num_uses; i++)
  	  {
*************** detect_web_parts_to_rebuild ()
*** 1544,1550 ****
  
    /* We also recheck unconditionally all uses of any hardregs.  This means
       we _can_ delete all these uses from the live_at_end[] bitmaps.
!      And because we sometimes delete insn referring to hardregs (when
       they became useless because they setup a rematerializable pseudo, which
       then was rematerialized), some of those uses will go away with the next
       df_analyse().  This means we even _must_ delete those uses from
--- 1544,1550 ----
  
    /* We also recheck unconditionally all uses of any hardregs.  This means
       we _can_ delete all these uses from the live_at_end[] bitmaps.
!      Because we sometimes delete insn referring to hardregs (when
       they became useless because they setup a rematerializable pseudo, which
       then was rematerialized), some of those uses will go away with the next
       df_analyse().  This means we even _must_ delete those uses from
*************** detect_web_parts_to_rebuild ()
*** 1559,1567 ****
  	    bitmap_set_bit (uses_as_bitmap, DF_REF_ID (link->ref));
        }
  
!   /* The information in live_at_end[] will be rebuild for all uses
!      we recheck, so clear it here (the uses of spilled webs, might
!      indeed not become member of it again).  */
    live_at_end -= 2;
    for (i = 0; i < (unsigned int) last_basic_block + 2; i++)
      bitmap_operation (live_at_end[i], live_at_end[i], uses_as_bitmap,
--- 1559,1567 ----
  	    bitmap_set_bit (uses_as_bitmap, DF_REF_ID (link->ref));
        }
  
!   /* The information in live_at_end[] will be rebuilt for all uses
!      we recheck, so clear it here (the uses of spilled webs might
!      indeed not become a member of it again).  */
    live_at_end -= 2;
    for (i = 0; i < (unsigned int) last_basic_block + 2; i++)
      bitmap_operation (live_at_end[i], live_at_end[i], uses_as_bitmap,
*************** static void
*** 1588,1594 ****
  delete_useless_defs ()
  {
    unsigned int i;
!   /* If the insn only sets the def without any sideeffect (besides
       clobbers or uses), we can delete it.  single_set() also tests
       for INSN_P(insn).  */
    EXECUTE_IF_SET_IN_BITMAP (useless_defs, 0, i,
--- 1588,1594 ----
  delete_useless_defs ()
  {
    unsigned int i;
!   /* If the insn only sets the def without any side effect (besides
       clobbers or uses), we can delete it.  single_set() also tests
       for INSN_P(insn).  */
    EXECUTE_IF_SET_IN_BITMAP (useless_defs, 0, i,
*************** delete_useless_defs ()
*** 1607,1616 ****
      });
  }
  
! /* Look for spilled webs, on whose behalf no insns were emitted.
!    We inversify (sp?) the changed flag of the webs, so after this function
!    a nonzero changed flag means, that this web was not spillable (at least
!    in this pass).  */
  
  static void
  detect_non_changed_webs ()
--- 1607,1616 ----
      });
  }
  
! /* Look for spilled webs on whose behalf no insns were emitted.
!    We invert the changed flag of the webs, so after this function,
!    a nonzero changed flag means that this web was not spillable (at least
!    not in this pass).  */
  
  static void
  detect_non_changed_webs ()
*************** detect_non_changed_webs ()
*** 1630,1642 ****
  	}
        else
  	web->changed = 0;
!       /* From now on web->changed is used as the opposite flag.
! 	 I.e. colored webs, which have changed set were formerly
  	 spilled webs for which no insns were emitted.  */
      }
  }
  
! /* Before spilling we clear the changed flags for all spilled webs.  */
  
  static void
  reset_changed_flag ()
--- 1630,1642 ----
  	}
        else
  	web->changed = 0;
!       /* From now on web->changed is used as the opposite flag,
! 	 i.e. colored webs, which have changed set were formerly
  	 spilled webs for which no insns were emitted.  */
      }
  }
  
! /* We clear the changed flags for all spilled webs before spilling.  */
  
  static void
  reset_changed_flag ()
*************** actual_spill ()
*** 1679,1689 ****
  }
  
  /* A bitmap of pseudo reg numbers which are coalesced directly
!    to a hardreg.  Set in emit_colors(), used and freed in
     remove_suspicious_death_notes().  */
  static bitmap regnos_coalesced_to_hardregs;
  
! /* Create new pseudos for each web we colored, change insns to
     use those pseudos and set up ra_reg_renumber.  */
  
  void
--- 1679,1689 ----
  }
  
  /* A bitmap of pseudo reg numbers which are coalesced directly
!    to a hardreg.  Set in emit_colors() and used and freed in
     remove_suspicious_death_notes().  */
  static bitmap regnos_coalesced_to_hardregs;
  
! /* Create new pseudos for each web we colored, and change insns to
     use those pseudos and set up ra_reg_renumber.  */
  
  void
*************** emit_colors (df)
*** 1698,1707 ****
    basic_block bb;
  
    /* This bitmap is freed in remove_suspicious_death_notes(),
!      which is also the user of it.  */
    regnos_coalesced_to_hardregs = BITMAP_XMALLOC ();
    /* First create the (REG xx) rtx's for all webs, as we need to know
!      the number, to make sure, flow has enough memory for them in the
       various tables.  */
    for (i = 0; i < num_webs - num_subwebs; i++)
      {
--- 1698,1707 ----
    basic_block bb;
  
    /* This bitmap is freed in remove_suspicious_death_notes(),
!      which also uses it.  */
    regnos_coalesced_to_hardregs = BITMAP_XMALLOC ();
    /* First create the (REG xx) rtx's for all webs, as we need to know
!      the number to make sure flow has enough memory for them in the
       various tables.  */
    for (i = 0; i < num_webs - num_subwebs; i++)
      {
*************** emit_colors (df)
*** 1736,1743 ****
        else
  	{
  	  /* Special case for i386 'fix_truncdi_nomemory' insn.
! 	     We must choose mode from insns not from PSEUDO_REGNO_MODE.
! 	     Actual only for clobbered register.  */
  	  if (web->num_uses == 0 && web->num_defs == 1)
  	    web->reg_rtx = gen_reg_rtx (GET_MODE (DF_REF_REAL_REG (web->defs[0])));
  	  else
--- 1736,1743 ----
        else
  	{
  	  /* Special case for i386 'fix_truncdi_nomemory' insn.
! 	     We must choose mode from insns not from PSEUDO_REGNO_MODE,
! 	     actually only for the clobbered register.  */
  	  if (web->num_uses == 0 && web->num_defs == 1)
  	    web->reg_rtx = gen_reg_rtx (GET_MODE (DF_REF_REAL_REG (web->defs[0])));
  	  else
*************** emit_colors (df)
*** 1753,1770 ****
    for (si = 0; si < max_regno; si++)
      ra_reg_renumber[si] = -1;
  
!   /* Then go through all references, and replace them by a new
!      pseudoreg for each web.  All uses.  */
    /* XXX
       Beware: The order of replacements (first uses, then defs) matters only
!      for read-mod-write insns, where the RTL expression for the REG is
!      shared between def and use.  For normal rmw insns we connected all such
       webs, i.e. both the use and the def (which are the same memory)
!      there get the same new pseudo-reg, so order would not matter.
!      _However_ we did not connect webs, were the read cycle was an
!      uninitialized read.  If we now would first replace the def reference
       and then the use ref, we would initialize it with a REG rtx, which
!      gets never initialized, and yet more wrong, which would overwrite
       the definition of the other REG rtx.  So we must replace the defs last.
     */
    for (i = 0; i < df->use_id; i++)
--- 1753,1770 ----
    for (si = 0; si < max_regno; si++)
      ra_reg_renumber[si] = -1;
  
!   /* Now go through all references, and replace them by a new
!      pseudoreg for each web for all uses.  */
    /* XXX
       Beware: The order of replacements (first uses, then defs) matters only
!      for read-modfy-write insns, where the RTL expression for the REG is
!      shared between the def and use.  For normal rmw insns we connected all such
       webs, i.e. both the use and the def (which are the same memory)
!      so they get the same new pseudo-reg, so order would not matter.
!      _However_, we did not connect webs where the read cycle was an
!      uninitialized read.  If we now first replace the def reference
       and then the use ref, we would initialize it with a REG rtx, which
!      is never initialized, and even worse, which would overwrite
       the definition of the other REG rtx.  So we must replace the defs last.
     */
    for (i = 0; i < df->use_id; i++)
*************** emit_colors (df)
*** 1787,1793 ****
  	  }
        }
  
!   /* And all defs.  */
    for (i = 0; i < df->def_id; i++)
      {
        regset rs;
--- 1787,1793 ----
  	  }
        }
  
!   /* Do all defs.  */
    for (i = 0; i < df->def_id; i++)
      {
        regset rs;
*************** emit_colors (df)
*** 1812,1818 ****
  	}
      }
  
!   /* And now set up the ra_reg_renumber array for reload with all the new
       pseudo-regs.  */
    for (i = 0; i < num_webs - num_subwebs; i++)
      {
--- 1812,1818 ----
  	}
      }
  
!   /* Now set up the ra_reg_renumber array for reload with all the new
       pseudo-regs.  */
    for (i = 0; i < num_webs - num_subwebs; i++)
      {
*************** delete_moves ()
*** 1844,1870 ****
  {
    struct move_list *ml;
    struct web *s, *t;
!   /* XXX Beware: We normally would test here each copy insn, if
!      source and target got the same color (either by coalescing or by pure
       luck), and then delete it.
!      This will currently not work.  One problem is, that we don't color
       the regs ourself, but instead defer to reload.  So the colorization
!      is only a kind of suggestion, which reload doesn't have to follow.
       For webs which are coalesced to a normal colored web, we only have one
       new pseudo, so in this case we indeed can delete copy insns involving
       those (because even if reload colors them different from our suggestion,
       it still has to color them the same, as only one pseudo exists).  But for
       webs coalesced to precolored ones, we have not a single pseudo, but
!      instead one for each coalesced web.  This means, that we can't delete
       copy insns, where source and target are webs coalesced to precolored
       ones, because then the connection between both webs is destroyed.  Note
       that this not only means copy insns, where one side is the precolored one
       itself, but also those between webs which are coalesced to one color.
!      Also because reload we can't delete copy insns which involve any
       precolored web at all.  These often have also special meaning (e.g.
       copying a return value of a call to a pseudo, or copying pseudo to the
       return register), and the deletion would confuse reload in thinking the
!      pseudo isn't needed.  One of those days reload will get away and we can
       do everything we want.
       In effect because of the later reload, we can't base our deletion on the
       colors itself, but instead need to base them on the newly created
--- 1844,1870 ----
  {
    struct move_list *ml;
    struct web *s, *t;
!   /* XXX Beware: We would normally test here each copy insn, if
!      source and target received the same color (either by coalescing or by pure
       luck), and then delete it.
!      This will currently not work.  One problem is that we don't color
       the regs ourself, but instead defer to reload.  So the colorization
!      is only a kind of suggestion which reload doesn't have to follow.
       For webs which are coalesced to a normal colored web, we only have one
       new pseudo, so in this case we indeed can delete copy insns involving
       those (because even if reload colors them different from our suggestion,
       it still has to color them the same, as only one pseudo exists).  But for
       webs coalesced to precolored ones, we have not a single pseudo, but
!      instead one for each coalesced web.  This means that we can't delete
       copy insns, where source and target are webs coalesced to precolored
       ones, because then the connection between both webs is destroyed.  Note
       that this not only means copy insns, where one side is the precolored one
       itself, but also those between webs which are coalesced to one color.
!      Also because of reload we can't delete copy insns which involve any
       precolored web at all.  These often have also special meaning (e.g.
       copying a return value of a call to a pseudo, or copying pseudo to the
       return register), and the deletion would confuse reload in thinking the
!      pseudo isn't needed.  One of those days reload will be removed and we can
       do everything we want.
       In effect because of the later reload, we can't base our deletion on the
       colors itself, but instead need to base them on the newly created
*************** delete_moves ()
*** 1887,1900 ****
  
  /* Due to reasons documented elsewhere we create different pseudos
     for all webs coalesced to hardregs.  For these parts life_analysis()
!    might have added REG_DEAD notes without considering, that only this part
!    but not the whole coalesced web dies.  The RTL is correct, there is no
     coalescing yet.  But if later reload's alter_reg() substitutes the
!    hardreg into the REG rtx it looks like that particular hardreg dies here,
     although (due to coalescing) it still is live.  This might make different
!    places of reload think, it can use that hardreg for reload regs,
!    accidentally overwriting it.  So we need to remove those REG_DEAD notes.
!    (Or better teach life_analysis() and reload about our coalescing, but
     that comes later) Bah.  */
  
  void
--- 1887,1900 ----
  
  /* Due to reasons documented elsewhere we create different pseudos
     for all webs coalesced to hardregs.  For these parts life_analysis()
!    might have added REG_DEAD notes without considering that only this part
!    but not the whole coalesced web dies.  The RTL is correct; there is no
     coalescing yet.  But if later reload's alter_reg() substitutes the
!    hardreg into the REG rtx it looks like that particular hardreg dies here
     although (due to coalescing) it still is live.  This might make different
!    pieces of reload think it can use that hardreg for reload regs and
!    accidentally overwrite it.  So we need to remove those REG_DEAD notes.
!    (Or better yet teach life_analysis() and reload about our coalescing, but
     that comes later) Bah.  */
  
  void


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