Commit 0676c393 by Mark Mitchell Committed by Mark Mitchell

final.c (shorten_branches): Do not align labels for jump tables.

	* final.c (shorten_branches): Do not align labels for jump tables.
	(final_scan_insn): Use JUMP_TABLE_DATA_P.

	* gcc.dg/falign-labels-1.c: New test.

Co-Authored-By: Maxim Kuvyrkov <maxim@codesourcery.com>

From-SVN: r147824
parent 94324dae
2009-05-23 Mark Mitchell <mark@codesourcery.com>
* final.c (shorten_branches): Do not align labels for jump tables.
(final_scan_insn): Use JUMP_TABLE_DATA_P.
2009-05-23 Eric Botcazou <ebotcazou@adacore.com> 2009-05-23 Eric Botcazou <ebotcazou@adacore.com>
* doc/passes.texi: Standardize spelling of RTL, Tree and Tree SSA. * doc/passes.texi: Standardize spelling of RTL, Tree and Tree SSA.
......
...@@ -901,6 +901,7 @@ shorten_branches (rtx first ATTRIBUTE_UNUSED) ...@@ -901,6 +901,7 @@ shorten_branches (rtx first ATTRIBUTE_UNUSED)
if (LABEL_P (insn)) if (LABEL_P (insn))
{ {
rtx next; rtx next;
bool next_is_jumptable;
/* Merge in alignments computed by compute_alignments. */ /* Merge in alignments computed by compute_alignments. */
log = LABEL_TO_ALIGNMENT (insn); log = LABEL_TO_ALIGNMENT (insn);
...@@ -910,22 +911,22 @@ shorten_branches (rtx first ATTRIBUTE_UNUSED) ...@@ -910,22 +911,22 @@ shorten_branches (rtx first ATTRIBUTE_UNUSED)
max_skip = LABEL_TO_MAX_SKIP (insn); max_skip = LABEL_TO_MAX_SKIP (insn);
} }
next = next_nonnote_insn (insn);
next_is_jumptable = next && JUMP_TABLE_DATA_P (next);
if (!next_is_jumptable)
{
log = LABEL_ALIGN (insn); log = LABEL_ALIGN (insn);
if (max_log < log) if (max_log < log)
{ {
max_log = log; max_log = log;
max_skip = LABEL_ALIGN_MAX_SKIP; max_skip = LABEL_ALIGN_MAX_SKIP;
} }
next = next_nonnote_insn (insn); }
/* ADDR_VECs only take room if read-only data goes into the text /* ADDR_VECs only take room if read-only data goes into the text
section. */ section. */
if (JUMP_TABLES_IN_TEXT_SECTION if ((JUMP_TABLES_IN_TEXT_SECTION
|| readonly_data_section == text_section) || readonly_data_section == text_section)
if (next && JUMP_P (next)) && next_is_jumptable)
{
rtx nextbody = PATTERN (next);
if (GET_CODE (nextbody) == ADDR_VEC
|| GET_CODE (nextbody) == ADDR_DIFF_VEC)
{ {
log = ADDR_VEC_ALIGN (next); log = ADDR_VEC_ALIGN (next);
if (max_log < log) if (max_log < log)
...@@ -934,7 +935,6 @@ shorten_branches (rtx first ATTRIBUTE_UNUSED) ...@@ -934,7 +935,6 @@ shorten_branches (rtx first ATTRIBUTE_UNUSED)
max_skip = LABEL_ALIGN_MAX_SKIP; max_skip = LABEL_ALIGN_MAX_SKIP;
} }
} }
}
LABEL_TO_ALIGNMENT (insn) = max_log; LABEL_TO_ALIGNMENT (insn) = max_log;
LABEL_TO_MAX_SKIP (insn) = max_skip; LABEL_TO_MAX_SKIP (insn) = max_skip;
max_log = 0; max_log = 0;
...@@ -2023,16 +2023,10 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, ...@@ -2023,16 +2023,10 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
app_disable (); app_disable ();
next = next_nonnote_insn (insn); next = next_nonnote_insn (insn);
if (next != 0 && JUMP_P (next)) /* If this label is followed by a jump-table, make sure we put
{ the label in the read-only section. Also possibly write the
rtx nextbody = PATTERN (next); label and jump table together. */
if (next != 0 && JUMP_TABLE_DATA_P (next))
/* If this label is followed by a jump-table,
make sure we put the label in the read-only section. Also
possibly write the label and jump table together. */
if (GET_CODE (nextbody) == ADDR_VEC
|| GET_CODE (nextbody) == ADDR_DIFF_VEC)
{ {
#if defined(ASM_OUTPUT_ADDR_VEC) || defined(ASM_OUTPUT_ADDR_DIFF_VEC) #if defined(ASM_OUTPUT_ADDR_VEC) || defined(ASM_OUTPUT_ADDR_DIFF_VEC)
/* In this case, the case vector is being moved by the /* In this case, the case vector is being moved by the
...@@ -2065,7 +2059,6 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, ...@@ -2065,7 +2059,6 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
#endif #endif
break; break;
} }
}
if (LABEL_ALT_ENTRY_P (insn)) if (LABEL_ALT_ENTRY_P (insn))
output_alternate_entry_point (file, insn); output_alternate_entry_point (file, insn);
else else
......
2009-05-23 Mark Mitchell <mark@codesourcery.com>
Maxim Kuvyrkov <maxim@codesourcery.com>
* gcc.dg/falign-labels-1.c: New test.
2009-05-23 Eric Botcazou <ebotcazou@adacore.com> 2009-05-23 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/specs/rep_clause3.ads: New test. * gnat.dg/specs/rep_clause3.ads: New test.
......
/* { dg-do run } */
/* { dg-options "-falign-labels=8" { target { ! { m68k*-*-* || fido*-*-* } } } } */
/* On ARMv7-A CPUs, this test resulted in incorrect code generation.
The code generated for the switch statement expected the jump table
to immediately follow the jump instruction, but -falign-labels
caused the label preceding the table to be aligned. */
/* M68K and fido only support -falign-labels argument <= 2. */
volatile int x;
int main(void)
{
int y;
x = 0;
switch(x)
{
case 0:
y = 2 * x;
break;
case 1:
y = -3 * x;
break;
case 2:
y = x + 5;
break;
case 3:
y = x - 7;
break;
default:
break;
}
x = y;
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment