This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Patches to reorg.c
- To: egcs-bugs at cygnus dot com
- Subject: Patches to reorg.c
- From: Herman ten Brugge <herman at htbrug dot net dot HCC dot nl>
- Date: Sat, 4 Oct 1997 12:28:12 +0100 (MET)
- Reply-To: Haj dot Ten dot Brugge at net dot HCC dot nl (Herman ten Brugge)
Hello Guys,
I found some bugs in reorg.c while helping to port the gcc compiler to
the C30/C40 dsp.
The bugs occur because this dsp has 3 instruction after the delayed branch.
The code in reorg.c is probably mostly used for a single delayed instruction.
Overview of patches:
- I modified the call to fill_slots_from_thread. This routine could be called
when there was already some code in the delay slot. This can happed at line
3320.
- Added a call to mark_set_resources at line 3636.
- Checked if the condition codes are modified by instructions in the delayed
branch slot in routine fill_slots_from_thread at line 3705.
- Marked correct resources in try_merge_delay_insns.
Herman.
--- reorg.c.org Sat Oct 4 11:30:32 1997
+++ reorg.c Thu Oct 2 16:54:41 1997
@@ -266,7 +266,7 @@
static void mark_target_live_regs PROTO((rtx, struct resources *));
static void fill_simple_delay_slots PROTO((rtx, int));
static rtx fill_slots_from_thread PROTO((rtx, rtx, rtx, rtx, int, int,
- int, int, int, int *));
+ int, int, int, int *, rtx));
static void fill_eager_delay_slots PROTO((rtx));
static void relax_delay_slots PROTO((rtx));
static void make_return_insns PROTO((rtx));
@@ -1888,9 +1888,13 @@
if (! annul_p)
mark_referenced_resources (next_to_match, &needed, 1);
}
-
- mark_set_resources (trial, &set, 0, 1);
- mark_referenced_resources (trial, &needed, 1);
+ else
+ {
+ /* We don't mark the resources when we pull them into the delay
+ slot because their results are ready anyway. */
+ mark_set_resources (trial, &set, 0, 1);
+ mark_referenced_resources (trial, &needed, 1);
+ }
}
/* See if we stopped on a filled insn. If we did, try to see if its
@@ -1935,6 +1939,12 @@
next_to_match = XVECEXP (PATTERN (insn), 0, slot_number);
}
+ else
+ {
+ /* Account for resources set/needed by the last insn. */
+ mark_set_resources (dtrial, &set, 0, 1);
+ mark_referenced_resources (dtrial, &needed, 1);
+ }
}
}
@@ -2159,6 +2169,10 @@
|| ! INSN_FROM_TARGET_P (candidate))
&& insn_sets_resource_p (candidate, &needed, 1))
return 0;
+
+ /* Account for resources set/needed by the last insn. */
+ mark_set_resources (candidate, &set, 0, 1);
+ mark_referenced_resources (candidate, &needed, 1);
}
@@ -3322,7 +3336,8 @@
NULL, 1, 1,
own_thread_p (JUMP_LABEL (insn),
JUMP_LABEL (insn), 0),
- 0, slots_to_fill, &slots_filled);
+ 0, slots_to_fill, &slots_filled,
+ delay_list);
if (delay_list)
unfilled_slots_base[i]
@@ -3452,7 +3467,7 @@
static rtx
fill_slots_from_thread (insn, condition, thread, opposite_thread, likely,
thread_if_true, own_thread, own_opposite_thread,
- slots_to_fill, pslots_filled)
+ slots_to_fill, pslots_filled, delay_list)
rtx insn;
rtx condition;
rtx thread, opposite_thread;
@@ -3460,9 +3475,9 @@
int thread_if_true;
int own_thread, own_opposite_thread;
int slots_to_fill, *pslots_filled;
+ rtx delay_list;
{
rtx new_thread;
- rtx delay_list = 0;
struct resources opposite_needed, set, needed;
rtx trial;
int lose = 0;
@@ -3636,6 +3651,8 @@
delay_list = add_to_delay_list (temp, delay_list);
+ mark_set_resources (trial, &opposite_needed, 0, 1);
+
if (slots_to_fill == ++(*pslots_filled))
{
/* Even though we have filled all the slots, we
@@ -3705,7 +3722,9 @@
{
/* If this is the `true' thread, we will want to follow the jump,
so we can only do this if we have taken everything up to here. */
- if (thread_if_true && trial == new_thread)
+ if (thread_if_true && trial == new_thread
+ && !insn_references_resource_p (XVECEXP (PATTERN (trial), 0, 0),
+ &opposite_needed, 0))
delay_list
= steal_delay_list_from_target (insn, condition, PATTERN (trial),
delay_list, &set, &needed,
@@ -3905,7 +3924,8 @@
= fill_slots_from_thread (insn, condition, insn_at_target,
fallthrough_insn, prediction == 2, 1,
own_target, own_fallthrough,
- slots_to_fill, &slots_filled);
+ slots_to_fill, &slots_filled,
+ delay_list);
if (delay_list == 0 && own_fallthrough)
{
@@ -3920,7 +3940,8 @@
= fill_slots_from_thread (insn, condition, fallthrough_insn,
insn_at_target, 0, 0,
own_fallthrough, own_target,
- slots_to_fill, &slots_filled);
+ slots_to_fill, &slots_filled,
+ delay_list);
}
}
else
@@ -3930,14 +3951,16 @@
= fill_slots_from_thread (insn, condition, fallthrough_insn,
insn_at_target, 0, 0,
own_fallthrough, own_target,
- slots_to_fill, &slots_filled);
+ slots_to_fill, &slots_filled,
+ delay_list);
if (delay_list == 0)
delay_list
= fill_slots_from_thread (insn, condition, insn_at_target,
next_active_insn (insn), 0, 1,
own_target, own_fallthrough,
- slots_to_fill, &slots_filled);
+ slots_to_fill, &slots_filled,
+ delay_list);
}
if (delay_list)
--
-------------------------------------------------------------------------
Herman ten Brugge Email: Haj.Ten.Brugge@net.HCC.nl