sh.c (pool_node): New field: part_of_sequence_p.

* config/sh/sh.c (pool_node): New field: part_of_sequence_p.
	(add_constant): Set it.
	(dump_table): Don't reorder a constant if part_of_sequence_p.
	(machine_dependent_reorg): Assume that float constants will
	stay in their original order if used as a sequence.

From-SVN: r59213
This commit is contained in:
Richard Sandiford 2002-11-18 12:46:48 +00:00 committed by Richard Sandiford
parent 180bde4f78
commit 3503150c4c
4 changed files with 77 additions and 24 deletions

View File

@ -1,3 +1,11 @@
2002-11-18 Richard Sandiford <rsandifo@redhat.com>
* config/sh/sh.c (pool_node): New field: part_of_sequence_p.
(add_constant): Set it.
(dump_table): Don't reorder a constant if part_of_sequence_p.
(machine_dependent_reorg): Assume that float constants will
stay in their original order if used as a sequence.
2002-11-18 Richard Sandiford <rsandifo@redhat.com>
* config/sh/sh.c (calc_live_regs): Update check for PIC liveness

View File

@ -2258,6 +2258,10 @@ typedef struct
rtx label; /* Label of value. */
rtx wend; /* End of window. */
enum machine_mode mode; /* Mode of value. */
/* True if this constant is accessed as part of a post-increment
sequence. Note that HImode constants are never accessed in this way. */
bool part_of_sequence_p;
} pool_node;
/* The maximum number of constants that can fit into one pool, since
@ -2331,12 +2335,16 @@ add_constant (x, mode, last_value)
/* Need a new one. */
pool_vector[pool_size].value = x;
if (last_value && rtx_equal_p (last_value, pool_vector[pool_size - 1].value))
lab = 0;
{
lab = 0;
pool_vector[pool_size - 1].part_of_sequence_p = true;
}
else
lab = gen_label_rtx ();
pool_vector[pool_size].mode = mode;
pool_vector[pool_size].label = lab;
pool_vector[pool_size].wend = NULL_RTX;
pool_vector[pool_size].part_of_sequence_p = (lab == 0);
if (lab && pool_window_label)
{
newref = gen_rtx_LABEL_REF (VOIDmode, pool_window_label);
@ -2409,7 +2417,7 @@ dump_table (scan)
break;
case SImode:
case SFmode:
if (align_insn)
if (align_insn && !p->part_of_sequence_p)
{
for (lab = p->label; lab; lab = LABEL_REFS (lab))
emit_label_before (lab, align_insn);
@ -3732,7 +3740,6 @@ machine_dependent_reorg (first)
behind. */
rtx barrier = find_barrier (num_mova, mova, insn);
rtx last_float_move, last_float = 0, *last_float_addr;
int may_need_align = 1;
if (num_mova && ! mova_p (mova))
{
@ -3790,27 +3797,11 @@ machine_dependent_reorg (first)
if (last_float
&& reg_set_between_p (r0_rtx, last_float_move, scan))
last_float = 0;
if (TARGET_SHCOMPACT)
{
/* The first SFmode constant after a DFmode
constant may be pulled before a sequence
of DFmode constants, so the second SFmode
needs a label, just in case. */
if (GET_MODE_SIZE (mode) == 4)
{
if (last_float && may_need_align)
last_float = 0;
may_need_align = 0;
}
if (last_float
&& (GET_MODE_SIZE (GET_MODE (last_float))
!= GET_MODE_SIZE (mode)))
{
last_float = 0;
if (GET_MODE_SIZE (mode) == 4)
may_need_align = 1;
}
}
if (last_float
&& TARGET_SHCOMPACT
&& GET_MODE_SIZE (mode) != 4
&& GET_MODE_SIZE (GET_MODE (last_float)) == 4)
last_float = 0;
lab = add_constant (src, mode, last_float);
if (lab)
emit_insn_before (gen_mova (lab), scan);

View File

@ -1,3 +1,7 @@
2002-11-18 Richard Sandiford <rsandifo@redhat.com>
* gcc.c-torture/execute/20021118-2.c: New test.
2002-11-18 Richard Sandiford <rsandifo@redhat.com>
* gcc.c-torture/execute/20021118-1.c: New test.

View File

@ -0,0 +1,50 @@
/* Originally added to test SH constant pool layout. t1() failed for
non-PIC and t2() failed for PIC. */
int t1 (float *f, int i,
void (*f1) (double),
void (*f2) (float, float))
{
f1 (3.0);
f[i] = f[i + 1];
f2 (2.5f, 3.5f);
}
int t2 (float *f, int i,
void (*f1) (double),
void (*f2) (float, float),
void (*f3) (float))
{
f3 (6.0f);
f1 (3.0);
f[i] = f[i + 1];
f2 (2.5f, 3.5f);
}
void f1 (double d)
{
if (d != 3.0)
abort ();
}
void f2 (float f1, float f2)
{
if (f1 != 2.5f || f2 != 3.5f)
abort ();
}
void f3 (float f)
{
if (f != 6.0f)
abort ();
}
int main ()
{
float f[3] = { 2.0f, 3.0f, 4.0f };
t1 (f, 0, f1, f2);
t2 (f, 1, f1, f2, f3);
if (f[0] != 3.0f && f[1] != 4.0f)
abort ();
exit (0);
}