public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kito Cheng <kito.cheng@sifive.com>
To: "Li, Pan2" <pan2.li@intel.com>
Cc: Robin Dapp <rdapp.gcc@gmail.com>,
	 "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	"juzhe.zhong@rivai.ai" <juzhe.zhong@rivai.ai>,
	 "Wang, Yanzhang" <yanzhang.wang@intel.com>
Subject: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding
Date: Tue, 25 Jul 2023 21:23:28 +0800	[thread overview]
Message-ID: <CALLt3TjBW5F-vVYWPozSth1QBvTTOAXzTewr1OauihxxGFipzQ@mail.gmail.com> (raw)
In-Reply-To: <MW5PR11MB59080DA88FE5D4CC12D88803A903A@MW5PR11MB5908.namprd11.prod.outlook.com>

Hi Robin:

Give few more context about the design:

The call fesetround could be any function in practice, and we never
know if that function might use dynamic rounding mode floating point
operation or not, also we don't know if it will be called fesetround
or not.

So that's why we want to restore before function call to make sure we
don't break rounding mode for any inner function, also backup the frm
after function call can handle the case if the inner function has
changed global rounding mode.

On Tue, Jul 25, 2023 at 7:53 PM Li, Pan2 <pan2.li@intel.com> wrote:
>
> Thanks Robin. Let me share one example for the CALL scenario, considering below code.
>
> external int fesetround(int rounding_mode);
>
> test_call_for_rm:
>                                                  <-        FRM X
>    vfadd RTZ (static)               <-        FRM RTZ
>                                                  <-        RESTORE FRM X
>    call fesetround RMM         <-        Change FRM to RMM during the call
>                                                  <-        Backup the FRM RMM
>    vfadd RUP (static)              <-         FRM RUP
>                                                  <-         Restore the FRM to RMM
>    ret
>
> When emit at the insn call, we need to emit 2 insns, one restore before the call and one backup after call, to ensure 2 things.
>
> 1. The static FRM should not pollute the call.
> 2. The updated FRM in the call will alive to the end of the cfun.
>
> Unfortunately, current mode switching cannot emit 2 insns as above, it mostly emits after. It become even worse when the call
> is the last insn of the bb, we try to do some special handling in needed function for this.
>
> And thank robin again for nits and cleanups, like previous/next_nonnote_nondebug_insn_bb.
>
> Pan
>
> -----Original Message-----
> From: Robin Dapp <rdapp.gcc@gmail.com>
> Sent: Tuesday, July 25, 2023 4:38 PM
> To: Li, Pan2 <pan2.li@intel.com>; gcc-patches@gcc.gnu.org
> Cc: rdapp.gcc@gmail.com; juzhe.zhong@rivai.ai; kito.cheng@sifive.com; Wang, Yanzhang <yanzhang.wang@intel.com>
> Subject: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding
>
> Hi Pan,
>
> > Given we have a call, we would like to restore before call and then
> > backup frm after call. Looks current mode switching cannot emit insn
> > like that, it can only either emit insn before (mostly) or after
> > (when NOTE_INSN_BASIC_BLOCK_P). Thus, we try to emit the one after
> > call when needed as a specially handling here.
>
> Would you mind explaining a bit more here?  As far as I know we can
> perform necessary mode switching (including saving necessary
> registers) directly after function entry and right before function
> exit.  Is this somehow too early or too late or cannot handle what
> you want?
>
> The patch in itself makes sense (apart from some nits and possible
> cleanups) but I'm still missing the bigger picture.  For me it gets
> more confusing with every patch to be honest :D
>
> Regards
>  Robin
>

  reply	other threads:[~2023-07-25 13:23 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-19  3:28 [PATCH v1] " pan2.li
2023-07-19  3:31 ` juzhe.zhong
2023-07-19  6:30   ` Li, Pan2
2023-07-20  6:43 ` [PATCH v4] " pan2.li
2023-07-20  6:47   ` juzhe.zhong
2023-07-21  3:11   ` juzhe.zhong
2023-07-21  6:44     ` Li, Pan2
2023-07-23 13:11 ` [PATCH v5] " pan2.li
2023-07-24  0:53   ` juzhe.zhong
2023-07-24  1:51     ` Li, Pan2
2023-07-24  2:45       ` Li, Pan2
2023-07-24  2:42 ` [PATCH v6] " pan2.li
2023-07-24 10:28   ` Robin Dapp
2023-07-24 11:59     ` Li, Pan2
2023-07-24 12:03       ` Li, Pan2
2023-07-25  5:51 ` [PATCH v7] " pan2.li
2023-07-25  6:07   ` Li, Pan2
2023-07-25  8:38     ` Robin Dapp
2023-07-25 11:53       ` Li, Pan2
2023-07-25 13:23         ` Kito Cheng [this message]
2023-07-25 14:12           ` Robin Dapp
2023-07-26 13:08             ` Robin Dapp
2023-07-26 21:40               ` Jeff Law
2023-07-26 22:21                 ` 钟居哲
2023-07-26 22:46                   ` Jeff Law
2023-07-26 22:56                     ` 钟居哲
2023-07-27  1:38                       ` Li, Pan2
2023-07-27  8:19                         ` Li, Pan2
2023-07-27  2:09               ` Li, Pan2
2023-07-27  7:25                 ` Robin Dapp
2023-07-27  8:26                   ` Li, Pan2
2023-07-27  8:41                     ` Robin Dapp
2023-07-27 10:27                       ` Li, Pan2
     [not found]             ` <63471C6E126E44CF+D1CEA4C9-0050-43CD-8DE3-26EBD7AEE6DA@rivai.ai>
2023-07-26 13:35               ` Li, Pan2
2023-07-26 13:43                 ` Li, Pan2
2023-07-26 13:46               ` Robin Dapp
2023-07-26 13:57                 ` Kito Cheng
2023-07-26 14:05                   ` Kito Cheng
2023-07-26 14:10                     ` Robin Dapp
2023-07-26 14:18                 ` 钟居哲
2023-07-26 14:30                   ` Li, Pan2
2023-07-26 15:34                     ` Kito Cheng
2023-07-26 16:00                       ` Palmer Dabbelt
2023-07-26 21:01                     ` Robin Dapp
2023-07-28  1:15 ` [PATCH v8] " pan2.li
2023-07-28 10:05   ` Robin Dapp
2023-07-28 12:34     ` Li, Pan2
2023-08-01  7:50       ` Kito Cheng
2023-08-01  8:00         ` Li, Pan2

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=CALLt3TjBW5F-vVYWPozSth1QBvTTOAXzTewr1OauihxxGFipzQ@mail.gmail.com \
    --to=kito.cheng@sifive.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=juzhe.zhong@rivai.ai \
    --cc=pan2.li@intel.com \
    --cc=rdapp.gcc@gmail.com \
    --cc=yanzhang.wang@intel.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).