* final.c (shorten_branches): Make value passed to LABEL_ALIGN
authoramylaar <amylaar@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 23 Feb 2000 17:18:15 +0000 (17:18 +0000)
committeramylaar <amylaar@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 23 Feb 2000 17:18:15 +0000 (17:18 +0000)
conform to documentation.
* sh.h (LABEL_ALIGN): If aligning loops, call sh_label_align
to check for special cases.
* sh-protos.h (sh_label_align): Declare.
* sh.c (sh_label_align): Define.

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

gcc/ChangeLog
gcc/config/sh/sh-protos.h
gcc/config/sh/sh.c
gcc/config/sh/sh.h
gcc/final.c

index 6a7833b..fa8f35e 100644 (file)
@@ -1,3 +1,12 @@
+Wed Feb 23 16:42:21 2000  J"orn Rennecke <amylaar@cygnus.co.uk>
+
+       * final.c (shorten_branches): Make value passed to LABEL_ALIGN
+       conform to documentation.
+       * sh.h (LABEL_ALIGN): If aligning loops, call sh_label_align
+       to check for special cases.
+       * sh-protos.h (sh_label_align): Declare.
+       * sh.c (sh_label_align): Define.
+
 2000-02-22  Andrew Haley  <aph@cygnus.com>
 
        * config/mips/mips.h (GAS_ASM_SPEC): Pass -mgp32/-mgp64 to gas.
index bb96225..273444b 100644 (file)
@@ -36,6 +36,7 @@ extern const char *output_far_jump PARAMS ((rtx, rtx));
 extern void machine_dependent_reorg PARAMS ((rtx));
 extern struct rtx_def *sfunc_uses_reg PARAMS ((rtx));
 extern int barrier_align PARAMS ((rtx));
+extern int sh_loop_align PARAMS ((rtx));
 extern int fp_zero_operand PARAMS ((rtx));
 extern int fp_one_operand PARAMS ((rtx));
 extern int fp_int_operand PARAMS ((rtx));
index 696c73c..8c10ca5 100644 (file)
@@ -2786,6 +2786,30 @@ barrier_align (barrier_or_label)
   return CACHE_LOG;
 }
 
+/* If we are inside a phony loop, almost any kind of label can turn up as the
+   first one in the loop.  Aligning a braf label causes incorrect switch
+   destination addresses; we can detect braf labels because they are
+   followed by a BARRIER.
+   Applying loop alignment to small constant or switch tables is a waste
+   of space, so we suppress this too.  */
+int
+sh_loop_align (label)
+     rtx label;
+{
+  rtx next = label;
+
+  do
+    next = next_nonnote_insn (next);
+  while (next && GET_CODE (next) == CODE_LABEL);
+
+  if (! next
+      || GET_RTX_CLASS (GET_CODE (next)) != 'i'
+      || GET_CODE (PATTERN (next)) == ADDR_DIFF_VEC
+      || recog_memoized (next) == CODE_FOR_consttable_2)
+    return 0;
+  return 2;
+}
+
 /* Exported to toplev.c.
 
    Do a final pass over the function, just before delayed branch
index ac80d28..808febf 100644 (file)
@@ -351,7 +351,8 @@ do {                                                                        \
   barrier_align (LABEL_AFTER_BARRIER)
 
 #define LOOP_ALIGN(A_LABEL) \
-  ((! optimize || TARGET_HARVARD || TARGET_SMALLCODE) ? 0 : 2)
+  ((! optimize || TARGET_HARVARD || TARGET_SMALLCODE) \
+   ? 0 : sh_loop_align (A_LABEL))
 
 #define LABEL_ALIGN(A_LABEL) \
 (                                                                      \
index c38b5ae..d5096fb 100644 (file)
@@ -1134,7 +1134,7 @@ shorten_branches (first)
                break;
              else if (GET_CODE (label) == CODE_LABEL)
                {
-                 log = LOOP_ALIGN (insn);
+                 log = LOOP_ALIGN (label);
                  if (max_log < log)
                    {
                      max_log = log;