[PATCH/RFC] Fix PR optimization/15100
Kaz Kojima
kkojima@rr.iij4u.or.jp
Thu May 13 10:31:00 GMT 2004
amylaar@spamcop.net (Joern Rennecke) wrote:
> So, your patch works, but it's not immediately apparent from the code
> why it works. The && place is a red herring.
>
> I think something like this would be clearer:
>
> /* If the insn carrying the REG_LIBCALL (*) note has been marked
> as NOTE_INSN_DELETED, find_reg_note returns NULL_RTX. */
> if (! tem)
> /* We're deleting either the last remaining instruction of a
> libcall sequence, or we are deleting both the first and
> the last instruction of a libcall sequence. In the latter
> case, none of the remaining insns (if any) of the libcall
> computes a libcall value, so they do not belong in a libcall
> sequence. Thus, drop the notes. */
> place = 0;
> /* Since the other side of the libcall still exists, there must
> be at least on insn left in that direction. */
> else if (! place)
> abort ()
> else XEXP (tem, 0) = place;
>
> (*): Use REG_RETVAL in the REG_LIBCALL case.
Looks cleaner and more descriptive. I run make bootstrap for 3.4.0
on i686-linux with the patch below and found no problems in regtest.
There are no regressions on x86-linux cross to sh4-linux with it and
I'll test it on native sh-linux too. For mainline, it would be better
to revisit this after the merges from tree-ssa settled. I guess that
the last patch might be enough for 3.4-branch. There were no complains
from targets other than SH on 3.4-branch about the current behavior
of distribute_notes and that patch seems hard to affect the cases
which are currently working.
Regards,
kaz
--
diff -uprN ORIG/gcc-3.4.0/gcc/combine.c LOCAL/gcc-3.4.0/gcc/combine.c
--- ORIG/gcc-3.4.0/gcc/combine.c 2004-02-21 22:24:43.000000000 +0900
+++ LOCAL/gcc-3.4.0/gcc/combine.c 2004-05-13 10:45:21.000000000 +0900
@@ -12582,12 +12582,22 @@ distribute_notes (rtx notes, rtx from_in
{
tem = find_reg_note (XEXP (note, 0), REG_LIBCALL, NULL_RTX);
place = prev_real_insn (from_insn);
- if (tem && place)
+ /* If the insn carrying the REG_LIBCALL note has been marked
+ as NOTE_INSN_DELETED, find_reg_note returns NULL_RTX. */
+ if (! tem)
+ /* We're deleting either the last remaining instruction of
+ a libcall sequence, or we are deleting both the first and
+ the last instruction of a libcall sequence. In the latter
+ case, none of the remaining insns (if any) of the libcall
+ computes a libcall value, so they do not belong in a
+ libcall sequence. Thus, drop the notes. */
+ place = 0;
+ else if (! place)
+ /* Since the other side of the libcall still exists, there
+ must be at least on insn left in that direction. */
+ abort ();
+ else
XEXP (tem, 0) = place;
- /* If we're deleting the last remaining instruction of a
- libcall sequence, don't add the notes. */
- else if (XEXP (note, 0) == from_insn)
- tem = place = 0;
}
break;
@@ -12599,12 +12609,22 @@ distribute_notes (rtx notes, rtx from_in
{
tem = find_reg_note (XEXP (note, 0), REG_RETVAL, NULL_RTX);
place = next_real_insn (from_insn);
- if (tem && place)
+ /* If the insn carrying the REG_RETVAL note has been marked
+ as NOTE_INSN_DELETED, find_reg_note returns NULL_RTX. */
+ if (! tem)
+ /* We're deleting either the last remaining instruction of
+ a libcall sequence, or we are deleting both the first and
+ the last instruction of a libcall sequence. In the latter
+ case, none of the remaining insns (if any) of the libcall
+ computes a libcall value, so they do not belong in a
+ libcall sequence. Thus, drop the notes. */
+ place = 0;
+ else if (! place)
+ /* Since the other side of the libcall still exists, there
+ must be at least on insn left in that direction. */
+ abort ();
+ else
XEXP (tem, 0) = place;
- /* If we're deleting the last remaining instruction of a
- libcall sequence, don't add the notes. */
- else if (XEXP (note, 0) == from_insn)
- tem = place = 0;
}
break;
More information about the Gcc-patches
mailing list