This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] speed up fixup_tail_calls
- From: Steven Bosscher <stevenb at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 9 May 2005 10:22:32 +0200
- Subject: [patch] speed up fixup_tail_calls
Hi,
If there are sibcalls in the current function, the REG_EQUIV notes
for the incoming arguments are purged. To do that, we walk the
entire insns chain.
But after staring at function.c for a little while, I am quite sure
that we only have REG_EQUIV notes at this point between the function
start and the NOTE_INSN_FUNCTION_BEG note. So there is no need to
walk insns chain, just looking at a small part of it should be good
enough.
I also noticed that fixup_tail_calls is the only user of
purge_reg_equiv_notes, so I folded the latter into the former.
Bootstrapped and tested on i686-pc-linux-gnu. OK for mainline?
Gr.
Steven
* calls.c (purge_reg_equiv_notes): Remove, fold into...
(fixup_tail_calls): ...here. Only look at insns between the
start of the function and the FUNCTION_BEG insn note.
Index: calls.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/calls.c,v
retrieving revision 1.388
diff -u -3 -p -r1.388 calls.c
--- calls.c 3 May 2005 17:55:25 -0000 1.388
+++ calls.c 9 May 2005 07:04:15 -0000
@@ -1766,30 +1766,6 @@ shift_return_value (enum machine_mode mo
return true;
}
-/* Remove all REG_EQUIV notes found in the insn chain. */
-
-static void
-purge_reg_equiv_notes (void)
-{
- rtx insn;
-
- for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
- {
- while (1)
- {
- rtx note = find_reg_note (insn, REG_EQUIV, 0);
- if (note)
- {
- /* Remove the note and keep looking at the notes for
- this insn. */
- remove_note (insn, note);
- continue;
- }
- break;
- }
- }
-}
-
/* Generate all the code for a function call
and return an rtx for its value.
Store the value in TARGET (specified as an rtx) if convenient.
@@ -3050,16 +3026,40 @@ expand_call (tree exp, rtx target, int i
this function's incoming arguments.
At the start of RTL generation we know the only REG_EQUIV notes
- in the rtl chain are those for incoming arguments, so we can safely
- flush any REG_EQUIV note.
+ in the rtl chain are those for incoming arguments, so we can look
+ for REG_EQUIV notes between the start of the function and the
+ NOTE_INSN_FUNCTION_BEG.
This is (slight) overkill. We could keep track of the highest
argument we clobber and be more selective in removing notes, but it
does not seem to be worth the effort. */
+
void
fixup_tail_calls (void)
{
- purge_reg_equiv_notes ();
+ rtx insn;
+
+ for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
+ {
+ /* There are never REG_EQUIV notes for the incoming arguments
+ after the NOTE_INSN_FUNCTION_BEG note, so stop if we see it. */
+ if (NOTE_P (insn)
+ && NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_BEG)
+ break;
+
+ while (1)
+ {
+ rtx note = find_reg_note (insn, REG_EQUIV, 0);
+ if (note)
+ {
+ /* Remove the note and keep looking at the notes for
+ this insn. */
+ remove_note (insn, note);
+ continue;
+ }
+ break;
+ }
+ }
}
/* Traverse an argument list in VALUES and expand all complex