aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <rsandifo@redhat.com>2002-11-18 12:46:48 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2002-11-18 12:46:48 +0000
commit3503150c4c5f3f6b5e7ba5d6430a419ff8d38fe2 (patch)
tree5ee06779c76524b019b4fcf122b1d4bad9b623f3 /gcc
parent180bde4f78fdc3c07ed45f8219a130f94a214171 (diff)
downloadgcc-3503150c4c5f3f6b5e7ba5d6430a419ff8d38fe2.zip
gcc-3503150c4c5f3f6b5e7ba5d6430a419ff8d38fe2.tar.gz
gcc-3503150c4c5f3f6b5e7ba5d6430a419ff8d38fe2.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/config/sh/sh.c39
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20021118-2.c50
4 files changed, 77 insertions, 24 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7ab6bca..5a61cca 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,13 @@
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
in compact code.
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index 1b3f92d..a26d92b 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 899f448..481a5f7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
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.
2002-11-16 Jakub Jelinek <jakub@redhat.com>
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 0000000..5c8c548
--- /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);
+}