public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Jin Ma <jinma@linux.alibaba.com>, gcc-patches@gcc.gnu.org
Cc: richard.sandiford@arm.com, kito.cheng@gmail.com,
	christoph.muellner@vrull.eu, jinma.contrib@gmail.com
Subject: Re: [PATCH] RISC-V: Handle no_insn in TARGET_SCHED_VARIABLE_ISSUE.
Date: Mon, 29 May 2023 06:46:01 -0600	[thread overview]
Message-ID: <6d0b4afa-171d-9e8e-d0f3-56571f14244e@gmail.com> (raw)
In-Reply-To: <20230529110121.1721-1-jinma@linux.alibaba.com>



On 5/29/23 05:01, Jin Ma wrote:
> Reference: https://github.com/gcc-mirror/gcc/commit/d0bc0cb66bcb0e6a5a5a31a9e900e8ccc98e34e5
> 
> RISC-V should also be implemented to handle no_insn patterns for pipelining.
> 
> gcc/ChangeLog:
> 
> 	* config/riscv/riscv.cc (riscv_sched_variable_issue): New function.
> 	(TARGET_SCHED_VARIABLE_ISSUE): New macro.
> ---
>   gcc/config/riscv/riscv.cc | 21 +++++++++++++++++++++
>   1 file changed, 21 insertions(+)
> 
> diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
> index 3954fc07a8b..559fa9cd7e0 100644
> --- a/gcc/config/riscv/riscv.cc
> +++ b/gcc/config/riscv/riscv.cc
> @@ -6225,6 +6225,24 @@ riscv_issue_rate (void)
>     return tune_param->issue_rate;
>   }
>   
> +/* Implement TARGET_SCHED_VARIABLE_ISSUE.  */
> +
> +static int
> +riscv_sched_variable_issue (FILE *, int, rtx_insn *insn, int more)
> +{
> +  if (DEBUG_INSN_P (insn))
> +    return more;
> +
> +  rtx_code code = GET_CODE (PATTERN (insn));
> +  if (code == USE || code == CLOBBER)
> +    return more;
> +
> +  if (get_attr_type (insn) == TYPE_UNKNOWN)
> +    return more;
> +
> +  return more - 1;
> +}
The problem is that INSN is *much* more likely to be a real instruction 
that takes real resources, even if it is TYPE_UNKNOWN.
TYPE_UNKNOWN here is actually an indicator of what I would consider a 
bug in the backend, specifically that we have INSNs that do not provide 
a mapping for the schedulers to suitable types.

With that in mind I'd much rather get to the point where we can do 
something like this for TYPE_UNKNOWN:

type = get_attr_type (insn);
gcc_assert (type != TYPE_UNKNOWN);

That way if we ever encounter a TYPE_UNKNOWN during development, we can 
fix it in the md files in a sensible manner.  I don't know if we are 
close to being able to do that.  We fixed a ton of stuff in bitmanip.md, 
but I don't think there's been a thorough review of the port to find 
other instances of TYPE_UNKNOWN INSNs.


The other thing if this code probably wants to handle GHOST type 
instructions.  While GHOST is used for instructions which generate no 
code, it might seem they should return "more" as those INSNs take no 
resources.  But GHOST is actually used for things like the blockage insn 
which should end a cycle from an issue standpoint.  So the right 
handling of a GHOST is something like this:

if (type == TYPE_GHOST)
   return 0;

Jeff

  reply	other threads:[~2023-05-29 12:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-29 11:01 Jin Ma
2023-05-29 12:46 ` Jeff Law [this message]
2023-08-09 19:56   ` Jeff Law
2023-08-11  2:12     ` Jin Ma
2023-08-11  2:30       ` Palmer Dabbelt
2023-08-11  3:19         ` Jeff Law
2023-08-11  3:45           ` Palmer Dabbelt
2023-08-11 13:29             ` Jeff Law
2023-08-14 20:33               ` Edwin Lu
2023-08-14 22:06                 ` Jeff Law
2023-08-11 13:22       ` Jeff Law

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=6d0b4afa-171d-9e8e-d0f3-56571f14244e@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=christoph.muellner@vrull.eu \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jinma.contrib@gmail.com \
    --cc=jinma@linux.alibaba.com \
    --cc=kito.cheng@gmail.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).