public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Terry Guo <flameroc@gmail.com>
Cc: richard.sandiford@arm.com, rdsandiford@googlemail.com,
	       GCC Patches <gcc-patches@gcc.gnu.org>,
	Hale Wang <hale.wang@arm.com>
Subject: Re: Ping : [PATCH] [gcc, combine] PR46164: Don't combine the insns if a volatile register is contained.
Date: Thu, 26 Feb 2015 06:23:00 -0000	[thread overview]
Message-ID: <20150226055537.GA15492@gate.crashing.org> (raw)
In-Reply-To: <CAGbRaL4HOT9jB0wJ+eS+BoAVmuULz-rv0tRVJKsZFLYESUsm+w@mail.gmail.com>

On Tue, Feb 17, 2015 at 11:39:34AM +0800, Terry Guo wrote:
> On Sun, Feb 15, 2015 at 7:35 PM, Segher Boessenkool
> <segher@kernel.crashing.org> wrote:
> > Hi Terry,
> >
> > I still think this is stage1 material.
> >
> >> +  /* Don't combine if dest contains a user specified register and i3 contains
> >> +     ASM_OPERANDS, because the user specified register (same with dest) in i3
> >> +     would be replaced by the src of insn which might be different with
> >> +     the user's expectation.  */
> >
> > "Do not eliminate a register asm in an asm input" or similar?  Text
> > explaining why REG_USERVAR_P && HARD_REGISTER_P works here would be
> > good to have, too.

> diff --git a/gcc/combine.c b/gcc/combine.c
> index f779117..aeb2854 100644
> --- a/gcc/combine.c
> +++ b/gcc/combine.c
> @@ -1779,7 +1779,7 @@ can_combine_p (rtx_insn *insn, rtx_insn *i3, rtx_insn *pred ATTRIBUTE_UNUSED,
>  {
>    int i;
>    const_rtx set = 0;
> -  rtx src, dest;
> +  rtx src, dest, asm_op;
>    rtx_insn *p;
>  #ifdef AUTO_INC_DEC
>    rtx link;
> @@ -1914,6 +1914,14 @@ can_combine_p (rtx_insn *insn, rtx_insn *i3, rtx_insn *pred ATTRIBUTE_UNUSED,
>    set = expand_field_assignment (set);
>    src = SET_SRC (set), dest = SET_DEST (set);
>  
> +  /* Use REG_USERVAR_P and HARD_REGISTER_P to check whether DEST is a user
> +     specified register, and do not eliminate such register if it is in an
> +     asm input because we may end up with something different with user's
> +     expectation.  */

That doesn't explain why this will hit (almost) only on register asms.
The user's expectation doesn't matter that much either: GCC would violate
its own documentation / promises, that matters more ;-)

> +  if (REG_P (dest) && REG_USERVAR_P (dest) && HARD_REGISTER_P (dest)
> +      && ((asm_op = extract_asm_operands (PATTERN (i3))) != NULL))

You do not need the temporary variable, nor the != 0 or the extra parens;
just write

     && extract_asm_operands (PATTERN (i3))

Cheers,


Segher

  reply	other threads:[~2015-02-26  5:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-09  1:42 Hale Wang
2015-02-12 15:54 ` Richard Sandiford
2015-02-12 22:16   ` Segher Boessenkool
2015-02-12 22:46     ` Jeff Law
2015-02-13  3:18     ` Hale Wang
2015-02-13  9:07     ` Richard Sandiford
2015-02-15 10:26       ` Terry Guo
2015-02-15 11:35         ` Segher Boessenkool
2015-02-17  3:39           ` Terry Guo
2015-02-26  6:23             ` Segher Boessenkool [this message]
2015-02-26 12:12               ` Terry Guo
2015-02-26 20:26                 ` 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=20150226055537.GA15492@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=flameroc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hale.wang@arm.com \
    --cc=rdsandiford@googlemail.com \
    --cc=richard.sandiford@arm.com \
    /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).