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]

Re: Your proposed change to loop.c


> ie, precisely why is it necessary to replace find_live_and and find_giv_uses.

I am talking about replacing find_life_end *with* find_giv_uses, and
it is to increase the rebustness of the compiler and the quality of the
generated code.

> Why is their existing implementation incorrect?

Hmmm, seems like my previous message got lost.
The fixing of the ix field setting led to infinite loops because it
aggravated hte bug with the later index handling.  These two changes
must be really done at the same time.

With this change in place, I think find_live_end is no longer
incorrect, but of course it still remains fragile and sub-optimal in
optimization.
This patch is intended as a short-term solution to stabilize the tree.

Wed May 12 21:49:04 1999  J"orn Rennecke <amylaar@cygnus.co.uk>

	loop.c (recombine_givs): Set ix field after sorting.
	(recombine_givs): Remove bogus index / giv lockstep looping.

Index: loop.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/loop.c,v
retrieving revision 1.170
diff -p -r1.170 loop.c
*** loop.c	1999/08/02 23:50:36	1.170
--- loop.c	1999/08/04 17:12:06
*************** recombine_givs (bl, loop_start, loop_end
*** 7217,7232 ****
        for (p = v->insn; INSN_UID (p) >= max_uid_for_loop; )
  	p = PREV_INSN (p);
        stats[i].start_luid = INSN_LUID (p);
-       v->ix = i;
        i++;
      }
  
    qsort (stats, giv_count, sizeof(*stats), cmp_recombine_givs_stats);
  
!   /* Do the actual most-recently-used recombination.  */
    for (last_giv = 0, i = giv_count - 1; i >= 0; i--)
      {
        v = giv_array[stats[i].giv_number];
        if (v->same)
  	{
  	  struct induction *old_same = v->same;
--- 7217,7234 ----
        for (p = v->insn; INSN_UID (p) >= max_uid_for_loop; )
  	p = PREV_INSN (p);
        stats[i].start_luid = INSN_LUID (p);
        i++;
      }
  
    qsort (stats, giv_count, sizeof(*stats), cmp_recombine_givs_stats);
  
!   /* Set up the ix field for each giv in stats to name
!      the corresponding index into stats, and
!      do the actual most-recently-used recombination.  */
    for (last_giv = 0, i = giv_count - 1; i >= 0; i--)
      {
        v = giv_array[stats[i].giv_number];
+       v->ix = i;
        if (v->same)
  	{
  	  struct induction *old_same = v->same;
*************** recombine_givs (bl, loop_start, loop_end
*** 7272,7279 ****
    ends_need_computing = 0;
    /* For each DEST_REG giv, compute lifetime starts, and try to compute
       lifetime ends from regscan info.  */
!   for (i = 0, v = bl->giv; v; v = v->next_iv)
      {
        if (v->ignore)
  	continue;
        if (v->giv_type == DEST_ADDR)
--- 7274,7282 ----
    ends_need_computing = 0;
    /* For each DEST_REG giv, compute lifetime starts, and try to compute
       lifetime ends from regscan info.  */
!   for (i = giv_count - 1; i >= 0; i--)
      {
+       v = giv_array[stats[i].giv_number];
        if (v->ignore)
  	continue;
        if (v->giv_type == DEST_ADDR)
*************** recombine_givs (bl, loop_start, loop_end
*** 7342,7348 ****
  		}
  	    }
  	}
-       i++;
      }
  
    /* If the regscan information was unconclusive for one or more DEST_REG
--- 7345,7350 ----
*************** recombine_givs (bl, loop_start, loop_end
*** 7366,7386 ****
  
    /* Set start_luid back to the last insn that sets the giv.  This allows
       more combinations.  */
!   for (i = 0, v = bl->giv; v; v = v->next_iv)
      {
        if (v->ignore)
  	continue;
        if (INSN_UID (v->insn) < max_uid_for_loop)
  	stats[i].start_luid = INSN_LUID (v->insn);
-       i++;
      }
  
    /* Now adjust lifetime ends by taking combined givs into account.  */
!   for (i = 0, v = bl->giv; v; v = v->next_iv)
      {
        unsigned luid;
        int j;
  
        if (v->ignore)
  	continue;
        if (v->same && ! v->same->ignore)
--- 7368,7389 ----
  
    /* Set start_luid back to the last insn that sets the giv.  This allows
       more combinations.  */
!   for (i = giv_count - 1; i >= 0; i--)
      {
+       v = giv_array[stats[i].giv_number];
        if (v->ignore)
  	continue;
        if (INSN_UID (v->insn) < max_uid_for_loop)
  	stats[i].start_luid = INSN_LUID (v->insn);
      }
  
    /* Now adjust lifetime ends by taking combined givs into account.  */
!   for (i = giv_count - 1; i >= 0; i--)
      {
        unsigned luid;
        int j;
  
+       v = giv_array[stats[i].giv_number];
        if (v->ignore)
  	continue;
        if (v->same && ! v->same->ignore)
*************** recombine_givs (bl, loop_start, loop_end
*** 7392,7398 ****
  	      > (unsigned) stats[j].end_luid - stats[j].start_luid)
  	    stats[j].end_luid = luid;
  	}
-       i++;
      }
  
    qsort (stats, giv_count, sizeof(*stats), cmp_recombine_givs_stats);
--- 7395,7400 ----


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