public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: <juzhe.zhong@rivai.ai>
To: "Bernhard Reutner-Fischer" <rep.dot.nop@gmail.com>,
	 gcc-patches <gcc-patches@gcc.gnu.org>
Cc: kito.cheng <kito.cheng@gmail.com>
Subject: Re: Re: [PATCH] RISC-V: Add fault first load C/C++ support
Date: Thu, 9 Mar 2023 06:22:38 +0800	[thread overview]
Message-ID: <C0193156B64314F2+202303090622382572370@rivai.ai> (raw)
In-Reply-To: <9A4FC141-459E-414B-BBA0-07D3275BCFFA@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2660 bytes --]

Address comment and fix it in this V2 patch:
https://gcc.gnu.org/pipermail/gcc-patches/2023-March/613608.html



juzhe.zhong@rivai.ai
 
From: Bernhard Reutner-Fischer
Date: 2023-03-09 05:16
To: juzhe.zhong; gcc-patches
CC: kito.cheng; Ju-Zhe Zhong
Subject: Re: [PATCH] RISC-V: Add fault first load C/C++ support
On 7 March 2023 07:21:23 CET, juzhe.zhong@rivai.ai wrote:
>From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
>
 
>+class vleff : public function_base
>+{
>+public:
>+  unsigned int call_properties (const function_instance &) const override
>+  {
>+    return CP_READ_MEMORY | CP_WRITE_CSR;
>+  }
>+
>+  gimple *fold (gimple_folder &f) const override
>+  {
>+    /* fold vleff (const *base, size_t *new_vl, size_t vl)
>+
>+       ====> vleff (const *base, size_t vl)
>+      new_vl = MEM_REF[read_vl ()].  */
>+
>+    auto_vec<tree, 8> vargs;
 
Where is that magic 8 coming from?
 
Wouldn't you rather have one temporary to hold this manually CSEd
 
nargs = gimple_call_num_args (f.call) - 2;
 
which you would use throughout this function as it does not seem to change?
 
Would you reserve something based off nargs for the auto_vec above?
If not, please add a comment where the 8 comes from?
 
thanks,
 
>+
>+    for (unsigned i = 0; i < gimple_call_num_args (f.call); i++)
>+      {
>+ /* Exclude size_t *new_vl argument.  */
>+ if (i == gimple_call_num_args (f.call) - 2)
>+   continue;
>+
>+ vargs.quick_push (gimple_call_arg (f.call, i));
>+      }
>+
>+    gimple *repl = gimple_build_call_vec (gimple_call_fn (f.call), vargs);
>+    gimple_call_set_lhs (repl, f.lhs);
>+
>+    /* Handle size_t *new_vl by read_vl.  */
>+    tree new_vl = gimple_call_arg (f.call, gimple_call_num_args (f.call) - 2);
>+    if (integer_zerop (new_vl))
>+      {
>+ /* This case happens when user passes the nullptr to new_vl argument.
>+    In this case, we just need to ignore the new_vl argument and return
>+    vleff instruction directly. */
>+ return repl;
>+      }
>+
>+    tree tmp_var = create_tmp_var (size_type_node, "new_vl");
>+    tree decl = get_read_vl_decl ();
>+    gimple *g = gimple_build_call (decl, 0);
>+    gimple_call_set_lhs (g, tmp_var);
>+    tree indirect
>+      = fold_build2 (MEM_REF, size_type_node,
>+      gimple_call_arg (f.call,
>+       gimple_call_num_args (f.call) - 2),
>+      build_int_cst (build_pointer_type (size_type_node), 0));
>+    gassign *assign = gimple_build_assign (indirect, tmp_var);
>+
>+    gsi_insert_after (f.gsi, assign, GSI_SAME_STMT);
>+    gsi_insert_after (f.gsi, g, GSI_SAME_STMT);
>+    return repl;
>+  }
>+
 
 

  reply	other threads:[~2023-03-08 22:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-07  6:21 juzhe.zhong
2023-03-08 21:16 ` Bernhard Reutner-Fischer
2023-03-08 22:22   ` juzhe.zhong [this message]
2023-03-10 10:37   ` 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=C0193156B64314F2+202303090622382572370@rivai.ai \
    --to=juzhe.zhong@rivai.ai \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kito.cheng@gmail.com \
    --cc=rep.dot.nop@gmail.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).