This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: The recent regclass.c change
- To: Jeffrey A Law <law at cygnus dot com>
- Subject: Re: The recent regclass.c change
- From: Bernd Schmidt <crux at Pool dot Informatik dot RWTH-Aachen dot DE>
- Date: Wed, 7 Oct 1998 15:25:59 +0200 (MET DST)
- cc: egcs-patches at cygnus dot com
>
> > This patch undoes the regclass.c change and disables duplicate_loop_exit_te > st
> > if a REG_WAS_0 note is found.
> Instead of disabling duplicate_loop_exit_test, just remove the REG_WAS_0 note.
> That's likely less intrusive from an optimization standpoint. Note that cse2
> might put it back, but it should do so in a safe way :-)
>
> > Do we actually need REG_WAS_0 still? As far as I can see it is used in
> > three machine descriptions to turn movl 0,reg to incl reg. The same
> > transformation ought to be done by the new reload_move2add pass, oughtn't
> > it?
> Excellent question. I'd say it's probably no longer needed, but we'd have to
> do a little testing.
>
> In theory, the code in i386.md which uses REG_WAS_0 should never trigger
> anymore (since the constant load should have been replaced with a mov2add
> sequence). I'd say pick a few big hunks of code (compiler, glibc, 2.1.xxx
> kernel?) and see if the REG_WAS_0 code in i386.md ever triggers. If not, then
> I'd say kill REG_WAS_0.
I tried with the kernel, and the REG_WAS_0 optimization does trigger still.
It appears that the move2add optimization requires RTX_COSTS to be tweaked.
This ought to be investigated, but for now I'm afraid I might break the
other cost calculations if I go mucking about with that macro, so this fix
here seems like a safer solution for now.
Note: the patch is untested.
Bernd
* jump.c (duplicate_loop_exit_test): Strip REG_WAS_0 notes off all
insns we're going to copy.
* regclass.c (reg_scan_mark_refs): Don't test X for NULL_RTX.
Index: jump.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/jump.c,v
retrieving revision 1.37
diff -u -p -r1.37 jump.c
--- jump.c 1998/09/02 14:49:17 1.37
+++ jump.c 1998/10/07 13:19:36
@@ -2434,8 +2434,7 @@ duplicate_loop_exit_test (loop_start)
has a REG_RETVAL or REG_LIBCALL note (hard to adjust)
is a NOTE_INSN_LOOP_BEG because this means we have a nested loop
is a NOTE_INSN_BLOCK_{BEG,END} because duplicating these notes
- are not valid
-
+ is not valid.
We also do not do this if we find an insn with ASM_OPERANDS. While
this restriction should not be necessary, copying an insn with
@@ -2480,6 +2479,10 @@ duplicate_loop_exit_test (loop_start)
break;
case JUMP_INSN:
case INSN:
+ /* The code below would grossly mishandle REG_WAS_0 notes,
+ so get rid of them here. */
+ while ((p = find_reg_note (insn, REG_WAS_0, NULL_RTX)) != 0)
+ remove_note (insn, p);
if (++num_insns > 20
|| find_reg_note (insn, REG_RETVAL, NULL_RTX)
|| find_reg_note (insn, REG_LIBCALL, NULL_RTX)
Index: regclass.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/regclass.c,v
retrieving revision 1.31
diff -u -p -r1.31 regclass.c
--- regclass.c 1998/10/02 01:34:34 1.31
+++ regclass.c 1998/10/07 13:19:51
@@ -1995,13 +1995,6 @@ reg_scan_mark_refs (x, insn, note_flag,
register rtx dest;
register rtx note;
- /* This can happen when scanning insns referenced by certain notes.
-
- It is unclear if we should be scanning such insns; until someone can
- say for sure this seems like the safest fix. */
- if (x == NULL_RTX)
- return;
-
code = GET_CODE (x);
switch (code)
{