gniibe@m17n.org: Re: target/4516: [SH] sh-unknown-linux-gnu: big jump table

Joern Rennecke joern.rennecke@st.com
Wed Feb 27 15:23:00 GMT 2002


Joern Rennecke wrote:
> I think we can get most of the benefit just by reinstating the calculation of
> the
> barrier-related alignments at each invocation of shorten_branches, i.e. copy
> the alignments calculated by compute_alignments rather than destructively
> altering them.

My last patch for this didn't quite work; I've included an updated version here.
-- 
--------------------------
SuperH
2430 Aztec West / Almondsbury / BRISTOL / BS32 4AQ
T:+44 1454 462330
-------------- next part --------------
Wed Feb 27 22:29:44 2002  J"orn Rennecke <joern.rennecke@superh.com>

	* final.c (precomputed_label_align, n_precomputed_align): New variables.
	(compute_alignments): Set them.
	(shorten_branches): Initialize label_align with a copy of
	precomputed_label_align.
	
*** final.c-ORIG	Tue Feb 26 11:58:45 2002
--- final.c	Tue Feb 26 18:39:03 2002
*************** struct label_alignment
*** 475,481 ****
  
  static rtx *uid_align;
  static int *uid_shuid;
! static struct label_alignment *label_align;
  
  /* Indicate that branch shortening hasn't yet been done.  */
  
--- 475,482 ----
  
  static rtx *uid_align;
  static int *uid_shuid;
! static struct label_alignment *label_align, *precomputed_label_align;
! static int n_precomputed_label_align;
  
  /* Indicate that branch shortening hasn't yet been done.  */
  
*************** compute_alignments ()
*** 799,814 ****
        free (label_align);
        label_align = 0;
      }
  
    max_labelno = max_label_num ();
    min_labelno = get_first_label_num ();
-   label_align = (struct label_alignment *)
-     xcalloc (max_labelno - min_labelno + 1, sizeof (struct label_alignment));
  
    /* If not optimizing or optimizing for size, don't assign any alignments.  */
    if (! optimize || optimize_size)
      return;
  
    for (i = 0; i < n_basic_blocks; i++)
      {
        basic_block bb = BASIC_BLOCK (i);
--- 800,822 ----
        free (label_align);
        label_align = 0;
      }
+   if (precomputed_label_align)
+     {
+       free (precomputed_label_align);
+       precomputed_label_align = 0;
+     }
+   n_precomputed_label_align = 0;
  
    max_labelno = max_label_num ();
    min_labelno = get_first_label_num ();
  
    /* If not optimizing or optimizing for size, don't assign any alignments.  */
    if (! optimize || optimize_size)
      return;
  
+   label_align = (struct label_alignment *)
+     xcalloc (max_labelno - min_labelno + 1, sizeof (struct label_alignment));
+   n_precomputed_label_align = max_labelno - min_labelno + 1;
    for (i = 0; i < n_basic_blocks; i++)
      {
        basic_block bb = BASIC_BLOCK (i);
*************** compute_alignments ()
*** 868,873 ****
--- 876,883 ----
        LABEL_TO_ALIGNMENT (label) = max_log;
        LABEL_TO_MAX_SKIP (label) = max_skip;
      }
+   precomputed_label_align = label_align;
+   label_align = 0;
  }
  
  /* Make a pass over all insns and compute their actual lengths by shortening
*************** shorten_branches (first)
*** 912,938 ****
  
    uid_shuid = (int *) xmalloc (max_uid * sizeof *uid_shuid);
  
-   if (max_labelno != max_label_num ())
      {
-       int old = max_labelno;
        int n_labels;
        int n_old_labels;
  
        max_labelno = max_label_num ();
  
        n_labels = max_labelno - min_labelno + 1;
!       n_old_labels = old - min_labelno + 1;
  
!       label_align = (struct label_alignment *) xrealloc
! 	(label_align, n_labels * sizeof (struct label_alignment));
  
        /* Range of labels grows monotonically in the function.  Abort here
           means that the initialization of array got lost.  */
        if (n_old_labels > n_labels)
  	abort ();
  
!       memset (label_align + n_old_labels, 0,
! 	      (n_labels - n_old_labels) * sizeof (struct label_alignment));
      }
  
    /* Initialize label_align and set up uid_shuid to be strictly
--- 922,948 ----
  
    uid_shuid = (int *) xmalloc (max_uid * sizeof *uid_shuid);
  
      {
        int n_labels;
        int n_old_labels;
  
        max_labelno = max_label_num ();
  
        n_labels = max_labelno - min_labelno + 1;
!       n_old_labels = n_precomputed_label_align;
!       if (! precomputed_label_align)
! 	n_old_labels = 0;
  
!       label_align = (struct label_alignment *) xcalloc
! 	(n_labels, sizeof (struct label_alignment));
  
        /* Range of labels grows monotonically in the function.  Abort here
           means that the initialization of array got lost.  */
        if (n_old_labels > n_labels)
  	abort ();
  
!       memcpy (label_align, precomputed_label_align,
! 	      n_old_labels * sizeof (struct label_alignment));
      }
  
    /* Initialize label_align and set up uid_shuid to be strictly


More information about the Gcc-patches mailing list