From 2148624a44cb575edab51bf505687e4f8ca6445d Mon Sep 17 00:00:00 2001 From: "J\"orn Rennecke" Date: Wed, 23 Feb 2000 17:18:15 +0000 Subject: [PATCH] final.c (shorten_branches): Make value passed to LABEL_ALIGN conform to documentation. * 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. From-SVN: r32114 --- gcc/ChangeLog | 9 +++++++++ gcc/config/sh/sh-protos.h | 1 + gcc/config/sh/sh.c | 24 ++++++++++++++++++++++++ gcc/config/sh/sh.h | 3 ++- gcc/final.c | 2 +- 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6a7833b5d45..fa8f35ed347 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +Wed Feb 23 16:42:21 2000 J"orn Rennecke + + * 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 * config/mips/mips.h (GAS_ASM_SPEC): Pass -mgp32/-mgp64 to gas. diff --git a/gcc/config/sh/sh-protos.h b/gcc/config/sh/sh-protos.h index bb962255dd0..273444b2c6d 100644 --- a/gcc/config/sh/sh-protos.h +++ b/gcc/config/sh/sh-protos.h @@ -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)); diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 696c73cd23f..8c10ca55ee9 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -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 diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h index ac80d2809ee..808febffe82 100644 --- a/gcc/config/sh/sh.h +++ b/gcc/config/sh/sh.h @@ -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) \ ( \ diff --git a/gcc/final.c b/gcc/final.c index c38b5ae43db..d5096fb15c8 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -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;