From 3503150c4c5f3f6b5e7ba5d6430a419ff8d38fe2 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Mon, 18 Nov 2002 12:46:48 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 8 +++ gcc/config/sh/sh.c | 39 ++++++--------- gcc/testsuite/ChangeLog | 4 ++ .../gcc.c-torture/execute/20021118-2.c | 50 +++++++++++++++++++ 4 files changed, 77 insertions(+), 24 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/20021118-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7ab6bca3324..5a61cca728e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2002-11-18 Richard Sandiford + + * 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 * config/sh/sh.c (calc_live_regs): Update check for PIC liveness diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 1b3f92d8a8b..a26d92b8339 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 899f448e323..481a5f71fda 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-11-18 Richard Sandiford + + * gcc.c-torture/execute/20021118-2.c: New test. + 2002-11-18 Richard Sandiford * gcc.c-torture/execute/20021118-1.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/execute/20021118-2.c b/gcc/testsuite/gcc.c-torture/execute/20021118-2.c new file mode 100644 index 00000000000..5c8c5484f81 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20021118-2.c @@ -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); +} -- 2.30.2