From: Richard Sandiford <rsandifo@nildram.co.uk>
To: Eric Botcazou <ebotcazou@libertysurf.fr>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [4.2 only] RFA: PR 33848: reload rematerialisation of labels
Date: Sat, 27 Oct 2007 11:02:00 -0000 [thread overview]
Message-ID: <87d4v0j42c.fsf@firetop.home> (raw)
In-Reply-To: <200710271053.00304.ebotcazou@libertysurf.fr> (Eric Botcazou's message of "Sat\, 27 Oct 2007 10\:53\:00 +0200")
Eric Botcazou <ebotcazou@libertysurf.fr> writes:
>> Well, we build jump labels immediately after expanding, and try to keep
>> them up-to-date when changing jumps later. Not keeping them up-to-date
>> would be a bug.
>
> It's 4.2.x so we have to be conservative and avoid pulling too long a string,
> that's why I would go for a very safe change in this case.
>
> The original code was:
>
> + /* If we're replacing a LABEL_REF with a register, add a
> + REG_LABEL note to indicate to flow which label this
> + register refers to. */
> + if (GET_CODE (*r->where) == LABEL_REF
> + && GET_CODE (insn) == JUMP_INSN)
> + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_LABEL,
> + XEXP (*r->where, 0),
> + REG_NOTES (insn));
>
> Then it was modified as follows
>
> @@ -6033,9 +6033,12 @@ subst_reloads (rtx insn)
> register refers to. */
> if (GET_CODE (*r->where) == LABEL_REF
> && JUMP_P (insn))
> - REG_NOTES (insn) = gen_rtx_INSN_LIST (REG_LABEL,
> - XEXP (*r->where, 0),
> - REG_NOTES (insn));
> + {
> + REG_NOTES (insn) = gen_rtx_INSN_LIST (REG_LABEL,
> + XEXP (*r->where, 0),
> + REG_NOTES (insn));
> + JUMP_LABEL (insn) = XEXP (*r->where, 0);
> + }
>
> /* Encapsulate RELOADREG so its machine mode matches what
> used to be there. Note that gen_lowpart_common will
>
>
> I'm afraid your change would void the original intent in the name of fixing
> the subsequent modification. Couldn't we find a middle-ground instead?
I don't think it would reopen the original wound. The change was for
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20606, and as Andrew says
in comment #3:
------------------------------------------------------------------------
(In reply to comment #2)
> Why is computed_jump_p (insn) not returning true?
Actually it is the following insn:
(jump_insn 169 222 170 19 (set (pc)
(reg:DI 0 ax)) 515 {*indirect_jump_rtx64} (nil)
(insn_list:REG_LABEL 172 (nil)))
Which is a computed goto but at this point we have a REG_LABEL which
causes computed_jump_p to return false
------------------------------------------------------------------------
In other words, by unconditionally adding a REG_LABEL note, regardless
of whether there was a JUMP_LABEL, reload was turning something that
satisfied computed_jump_p into something that was neither a computed
jump nor a correct register-indirect jump to a known target.
My patch fixes the same bug by making sure that we only attach
a REG_LABEL note to jumps that already have a known target.
So with my patch, the jump in the testcase would still satsify
computed_jump_p after reload. And I think it's a valid fix.
While turning a computed jump into a jump to a known target
is an interesting optimisation, this is not the place to do it.
Reload only sees a LABEL_REF here because the original pseudo
did not get allocated a hard register, and the transformation
from a computed jump to a jump to a known target should not
depend on register allocation failure. The code above is purely
book keeping; the net effect of reload doesn't change the form
of the instruction, which is register-indirect both before and
after register allocation.
Richard
next prev parent reply other threads:[~2007-10-27 9:32 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-23 18:46 Richard Sandiford
2007-10-26 20:44 ` Eric Botcazou
2007-10-27 10:51 ` Richard Sandiford
2007-10-27 11:01 ` Eric Botcazou
2007-10-27 11:02 ` Richard Sandiford [this message]
2007-10-27 11:38 ` Eric Botcazou
2007-10-27 11:43 ` Richard Sandiford
2007-10-27 12:05 ` Eric Botcazou
2007-10-27 12:47 ` Richard Sandiford
2007-10-27 14:19 ` Eric Botcazou
2007-10-27 14:28 ` Richard Sandiford
2007-10-28 12:04 ` Richard Sandiford
2007-10-29 13:41 ` Eric Botcazou
2007-10-29 21:56 ` Richard Sandiford
2007-10-29 22:42 ` Eric Botcazou
2007-11-04 23:57 ` Mark Mitchell
2007-11-12 20:38 ` Richard Sandiford
2007-11-12 21:48 ` Ulrich Weigand
2007-11-12 22:13 ` Richard Sandiford
2007-11-13 23:09 ` Ulrich Weigand
2007-11-13 23:31 ` Richard Sandiford
2007-11-14 4:13 ` Ulrich Weigand
2007-11-21 10:07 ` Richard Sandiford
2007-11-22 10:55 ` Ulrich Weigand
2007-11-23 10:32 ` Richard Sandiford
2007-11-23 10:41 ` Richard Sandiford
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d4v0j42c.fsf@firetop.home \
--to=rsandifo@nildram.co.uk \
--cc=ebotcazou@libertysurf.fr \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).