]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* final.c: Undo my previous accidental checkin.
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 17 Aug 2001 13:45:59 +0000 (13:45 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 17 Aug 2001 13:45:59 +0000 (13:45 +0000)
* output.h: Likewise.
* tm.texi: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@44960 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/doc/tm.texi
gcc/final.c
gcc/output.h

index 87a50a6fc393eb05f9d7e834121a41d8df63d5e2..1212a519ecfdc4f53a6530e739c06cf5efe1b817 100644 (file)
@@ -1,3 +1,9 @@
+Fri Aug 17 15:41:35 CEST 2001  Jan Hubicka  <jh@suse.cz>
+
+       * final.c: Undo my previous accidental checkin.
+       * output.h: Likewise.
+       * tm.texi: Likewise.
+
 2001-08-16  Richard Henderson  <rth@redhat.com>
 
        * varasm.c (named_section_flags): Remove align parameter.
index 1a99fc5564d60af65815f030c584cb4a6bb157fd..538888b16d496927d882913661be7b0ef6aecdaa 100644 (file)
@@ -7137,20 +7137,6 @@ the target supports DWARF 2 frame unwind information.
 This describes commands for alignment.
 
 @table @code
-@findex JUMP_ALIGN_AFTER_BARRIER
-@item JUMP_ALIGN (@var{label})
-The alignment (log base 2) to put in front of @var{label}, which is
-a common destination of jumps and has no fallthru incomming edge.
-
-This macro need not be defined if you don't want any special alignment
-to be done at such a time.  Most machine descriptions do not currently
-define the macro.
-
-Unless it's necessary to inspect the @var{label} parameter, it is better
-to set the variable @var{align_jumps} in the target's
-@code{OVERRIDE_OPTIONS}.  Otherwise, you should try to honour the user's
-selection in @var{align_jumps} in a @code{JUMP_ALIGN} implementation.
-
 @findex LABEL_ALIGN_AFTER_BARRIER
 @item LABEL_ALIGN_AFTER_BARRIER (@var{label})
 The alignment (log base 2) to put in front of @var{label}, which follows
@@ -7160,6 +7146,12 @@ This macro need not be defined if you don't want any special alignment
 to be done at such a time.  Most machine descriptions do not currently
 define the macro.
 
+Unless it's necessary to inspect the @var{label} parameter, it is better
+to set the variable @var{align_jumps} in the target's
+@code{OVERRIDE_OPTIONS}.  Otherwise, you should try to honour the user's
+selection in @var{align_jumps} in a @code{LABEL_ALIGN_AFTER_BARRIER}
+implementation.
+
 @findex LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP
 @item LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP
 The maximum number of bytes to skip when applying
index 821a814fa45378fef1367c6b05ac9a105067c190..d32248196a0066c1045a5b4e90766203d6c2e670 100644 (file)
@@ -632,6 +632,11 @@ static struct label_alignment *label_align;
 void
 init_insn_lengths ()
 {
+  if (label_align)
+    {
+      free (label_align);
+      label_align = 0;
+    }
   if (uid_shuid)
     {
       free (uid_shuid);
@@ -775,19 +780,11 @@ get_attr_length (insn)
 #endif
 
 #ifndef LABEL_ALIGN_AFTER_BARRIER
-#define LABEL_ALIGN_AFTER_BARRIER(LABEL) 1
+#define LABEL_ALIGN_AFTER_BARRIER(LABEL) align_jumps_log
 #endif
 
 #ifndef LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP
-#define LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP 0
-#endif
-
-#ifndef JUMP_ALIGN
-#define JUMP_ALIGN(LABEL) align_jumps_log
-#endif
-
-#ifndef JUMP_ALIGN_MAX_SKIP
-#define JUMP_ALIGN_MAX_SKIP (align_jumps-1)
+#define LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP (align_jumps-1)
 #endif
 
 #ifndef ADDR_VEC_ALIGN
@@ -938,85 +935,6 @@ insn_current_reference_address (branch)
 }
 #endif /* HAVE_ATTR_length */
 \f
-void
-compute_alignments ()
-{
-  int i;
-  int log, max_skip, max_log;
-
-  if (label_align)
-    {
-      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.  */
-  for (i = 0; i < n_basic_blocks; i++)
-    {
-      basic_block bb = BASIC_BLOCK (i);
-      rtx label = bb->head;
-      int fallthru_frequency = 0, branch_frequency = 0, has_fallthru = 0;
-      edge e;
-
-      if (GET_CODE (label) != CODE_LABEL)
-       continue;
-      max_log = LABEL_ALIGN (label);
-      max_skip = LABEL_ALIGN_MAX_SKIP;
-
-      for (e = bb->pred; e; e = e->pred_next)
-       {
-         if (e->flags & EDGE_FALLTHRU)
-           has_fallthru = 1, fallthru_frequency += EDGE_FREQUENCY (e);
-         else
-           branch_frequency += EDGE_FREQUENCY (e);
-       }
-
-      /* There are two purposes to align block with no fallthru incomming edge:
-        1) to avoid fetch stalls when branch destination is near cache boundary
-        2) to improve cache effciency in case the previous block is not executed
-           (so it does not need to be in the cache).
-
-        We to catch first case, we align frequently executed blocks.
-        To catch the second, we align blocks that are executed more frequently
-        than the predecesor and the predecesor is likely to not be executed
-        when function is called.  */
-
-      if (!has_fallthru
-         && (branch_frequency > BB_FREQ_MAX / 10
-             || (bb->frequency > BASIC_BLOCK (i - 1)->frequency * 10
-                 && (BASIC_BLOCK (i - 1)->frequency
-                     <= ENTRY_BLOCK_PTR->frequency / 2))))
-       {
-         log = JUMP_ALIGN (label);
-         if (max_log < log)
-           {
-             max_log = log;
-             max_skip = JUMP_ALIGN_MAX_SKIP;
-           }
-       }
-      /* In case block is frequent and reached mostly by non-fallthru edge,
-        align it.  It is most likely an first block of loop.  */
-      if (has_fallthru
-         && branch_frequency + fallthru_frequency > BB_FREQ_MAX / 10
-         && branch_frequency > fallthru_frequency * 5)
-       {
-         log = LOOP_ALIGN (label);
-         if (max_log < log)
-           {
-             max_log = log;
-             max_skip = LOOP_ALIGN_MAX_SKIP;
-           }
-       }
-      LABEL_TO_ALIGNMENT (label) = max_log;
-      LABEL_TO_MAX_SKIP (label) = max_skip;
-    }
-}
-\f
 /* Make a pass over all insns and compute their actual lengths by shortening
    any branches of variable length if possible.  */
 
@@ -1054,29 +972,20 @@ shorten_branches (first)
 
 #endif
 
-  /* Compute maximum UID and allocate label_align / uid_shuid.  */
-  max_uid = get_max_uid ();
+  /* We must do some computations even when not actually shortening, in
+     order to get the alignment information for the labels.  */
 
-  uid_shuid = (int *) xmalloc (max_uid * sizeof *uid_shuid);
+  init_insn_lengths ();
 
-  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;
+  /* Compute maximum UID and allocate label_align / uid_shuid.  */
+  max_uid = get_max_uid ();
 
-      label_align = (struct label_alignment *) xrealloc
-       (label_align, n_labels * sizeof (struct label_alignment));
+  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 (n_old_labels < n_labels)
-       memset (label_align + n_old_labels, 0,
-               (n_labels - n_old_labels) * sizeof (struct label_alignment));
-    }
+  uid_shuid = (int *) xmalloc (max_uid * sizeof *uid_shuid);
 
   /* Initialize label_align and set up uid_shuid to be strictly
      monotonically rising with insn order.  */
@@ -1103,14 +1012,6 @@ shorten_branches (first)
       else if (GET_CODE (insn) == CODE_LABEL)
        {
          rtx next;
-         
-         /* Merge in alignments computed by compute_alignments.  */
-         log = LABEL_TO_ALIGNMENT (insn);
-         if (max_log < log)
-           {
-             max_log = log;
-             max_skip = LABEL_TO_MAX_SKIP (insn);
-           }
 
          log = LABEL_ALIGN (insn);
          if (max_log < log)
@@ -1162,6 +1063,41 @@ shorten_branches (first)
                break;
              }
        }
+      /* Again, we allow NOTE_INSN_LOOP_BEG - INSN - CODE_LABEL
+        sequences in order to handle reorg output efficiently.  */
+      else if (GET_CODE (insn) == NOTE
+              && NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_BEG)
+       {
+         rtx label;
+         int nest = 0;
+
+         /* Search for the label that starts the loop.
+            Don't skip past the end of the loop, since that could
+            lead to putting an alignment where it does not belong.
+            However, a label after a nested (non-)loop would be OK.  */
+         for (label = insn; label; label = NEXT_INSN (label))
+           {
+             if (GET_CODE (label) == NOTE
+                 && NOTE_LINE_NUMBER (label) == NOTE_INSN_LOOP_BEG)
+               nest++;
+             else if (GET_CODE (label) == NOTE
+                      && NOTE_LINE_NUMBER (label) == NOTE_INSN_LOOP_END
+                      && --nest == 0)
+               break;
+             else if (GET_CODE (label) == CODE_LABEL)
+               {
+                 log = LOOP_ALIGN (label);
+                 if (max_log < log)
+                   {
+                     max_log = log;
+                     max_skip = LOOP_ALIGN_MAX_SKIP;
+                   }
+                 break;
+               }
+           }
+       }
+      else
+       continue;
     }
 #ifdef HAVE_ATTR_length
 
index 6b8ffbcd37b3772cba438969e2d744d2c73d9cfc..b5aea51efedac32af0d15281c5cdc647754136d7 100644 (file)
@@ -20,9 +20,6 @@ along with GNU CC; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Compute branch alignments based on frequency information in the CFG.  */
-extern void compute_alignments  PARAMS ((void));
-
 /* Initialize data in final at the beginning of a compilation.  */
 extern void init_final         PARAMS ((const char *));