RE: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-27 Thread Li, Pan2 via Gcc-patches
org; juzhe.zh...@rivai.ai; Wang, Yanzhang Subject: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding > I see, you mean at the beginning of frm_after, we can just return the > incoming mode as is? > > If (CALL_P (insn)) > return mode; // Given we

Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-27 Thread Robin Dapp via Gcc-patches
> I see, you mean at the beginning of frm_after, we can just return the > incoming mode as is? > > If (CALL_P (insn)) > return mode; // Given we aware the mode is DYN_CALL already. Yes, potentially similar for all the other ifs but I didn't check all of them. > Thank and will cleanup this i

RE: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-27 Thread Li, Pan2 via Gcc-patches
: Li, Pan2 ; Kito Cheng Cc: rdapp@gmail.com; gcc-patches@gcc.gnu.org; juzhe.zh...@rivai.ai; Wang, Yanzhang Subject: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding >> Why do we appear to return a different mode here? We already request >> FRM_MODE_DYN_CA

RE: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-27 Thread Li, Pan2 via Gcc-patches
Law ; rdapp.gcc ; kito.cheng Cc: gcc-patches ; Wang, Yanzhang Subject: RE: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding Thanks Juzhe and Jeff for suggestion. The approach like emit_insn_before_noloc will result in below ICE here. ../../../.././gcc/libs

Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-27 Thread Robin Dapp via Gcc-patches
>> Why do we appear to return a different mode here? We already request >> FRM_MODE_DYN_CALL in mode_needed. It looks like in the whole function >> we do not change the mode so we could just always return the incoming >> mode? > > Because we need to emit 2 insn when meet a call. One before the c

RE: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread Li, Pan2 via Gcc-patches
ail.com; gcc-patches@gcc.gnu.org; juzhe.zh...@rivai.ai; Wang, Yanzhang Subject: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding So after thinking about it again - I'm still not really sure I like treating every function as essentially an fesetround. There is a r

RE: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread Li, Pan2 via Gcc-patches
handling when end bb is CALL. Pan From: 钟居哲 Sent: Thursday, July 27, 2023 6:56 AM To: Jeff Law ; rdapp.gcc ; kito.cheng ; Li, Pan2 Cc: gcc-patches ; Wang, Yanzhang Subject: Re: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding Thanks Jeff. Hi, Pan: Plz try (insert

Re: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread 钟居哲
Jeff Law Date: 2023-07-27 06:46 To: 钟居哲; rdapp.gcc; kito.cheng; pan2.li CC: gcc-patches; yanzhang.wang Subject: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding On 7/26/23 16:21, 钟居哲 wrote: > Hi, Jeff. > > insert_insn_end_basic_block is to handle this followi

Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread Jeff Law via Gcc-patches
On 7/26/23 16:21, 钟居哲 wrote: Hi, Jeff. insert_insn_end_basic_block is to handle this following case: bb 1: ... CALL.>BB_END of bb bb 2: vfadd rne You can see there is no instructions after CALL. So you we use insert_insn_end_basic_block insert a "frrm" at the end of the bb 1. I know

Re: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread 钟居哲
ivai.ai From: Jeff Law Date: 2023-07-27 05:40 To: Robin Dapp; Kito Cheng; Li, Pan2 CC: gcc-patches@gcc.gnu.org; juzhe.zh...@rivai.ai; Wang, Yanzhang Subject: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding On 7/26/23 07:08, Robin Dapp via Gcc-patches wrote: &g

Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread Jeff Law via Gcc-patches
On 7/26/23 07:08, Robin Dapp via Gcc-patches wrote: So after thinking about it again - I'm still not really sure I like treating every function as essentially an fesetround. There is a reason why fesetround is special. Does LLVM behave the same way? But supposing we really, really want it an

Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread Robin Dapp via Gcc-patches
> I would like to propose that being focus and moving forward for this > patch itself, the underlying other RVV floating point API support and > the RVV instrinsic API fully tests depend on this. Sorry, I didn't mean to ditch LCM/mode switching. I believe it is doing a pretty good job and we shou

Re: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread Palmer Dabbelt
钟居哲 *Sent:* Wednesday, July 26, 2023 10:18 PM *To:* rdapp.gcc ; Li, Pan2 *Cc:* rdapp.gcc ; kito.cheng ; gcc-patches ; Wang, Yanzhang < yanzhang.w...@intel.com> *Subject:* Re: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding Explicitly backup and restore for

Re: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread Kito Cheng via Gcc-patches
give up LCM/PRE chance then just backup and restore for > each intrinsic bindly. > > > > > -- > > juzhe.zh...@rivai.ai > > > > *From:* Robin Dapp > > *Date:* 2023-07-26 21:46 > > *To:* juzhe.zhong ; Li, Pan2 > >

RE: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread Li, Pan2 via Gcc-patches
Yanzhang<mailto:yanzhang.w...@intel.com> Subject: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding > current llvm didn't do any pre optimization. They always > backup+restore for each rounding mode intrinsic I see. There is still the option of lazily restor

Re: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread 钟居哲
ubject: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding > current llvm didn't do any pre optimization. They always > backup+restore for each rounding mode intrinsic I see. There is still the option of lazily restoring the (entry) FRM before a function call but n

Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread Robin Dapp via Gcc-patches
> CSR write could be expensive, it will flush whole pipeline in some > RISC-V core implementation… Hopefully not flush but just sequentialize but yes, it's usually a performance concern. However if we set the rounding mode to something else for an intrinsic and then call a function we want to re

Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread Kito Cheng via Gcc-patches
CSR write could be expensive, it will flush whole pipeline in some RISC-V core implementation… Kito Cheng 於 2023年7月26日 週三,21:57寫道: > Sorry for late ack on the LLVM part, I can say they are did the same > model/semantics, it done by our team member too, and I have regular meeting > with that guy :

Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread Kito Cheng via Gcc-patches
Sorry for late ack on the LLVM part, I can say they are did the same model/semantics, it done by our team member too, and I have regular meeting with that guy :P Robin Dapp via Gcc-patches 於 2023年7月26日 週三,21:47寫道: > > current llvm didn't do any pre optimization. They always > > backup+restore fo

Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread Robin Dapp via Gcc-patches
> current llvm didn't do any pre optimization. They always > backup+restore for each rounding mode intrinsic I see. There is still the option of lazily restoring the (entry) FRM before a function call but not read the FRM after every call. Do we have any data on how good or bad the mode-switchi

RE: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread Li, Pan2 via Gcc-patches
pp Cc: Kito Cheng ; rdapp@gmail.com; gcc-patches@gcc.gnu.org; Wang, Yanzhang Subject: RE: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding Thanks Robin for comments. Yes, you can reference this link to compare the difference between gcc and llvm. And I am trying to unde

RE: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread Li, Pan2 via Gcc-patches
, Pan2 ; rdapp@gmail.com; gcc-patches@gcc.gnu.org; Wang, Yanzhang Subject: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding current llvm didn't do any pre optimization. They always backup+restore for each rounding mode intrinsic We should not reference cu

Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-26 Thread Robin Dapp via Gcc-patches
So after thinking about it again - I'm still not really sure I like treating every function as essentially an fesetround. There is a reason why fesetround is special. Does LLVM behave the same way? But supposing we really, really want it and assuming there's consensus: + start_sequence (); + e

Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-25 Thread Robin Dapp via Gcc-patches
> 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 >

Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-25 Thread Kito Cheng via Gcc-patches
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 > Sent: Tuesday, July 25, 2023 4:38 PM > To: Li, Pan2 ; gcc-patches@gcc.gnu.org > Cc

RE: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-25 Thread Li, Pan2 via Gcc-patches
note_nondebug_insn_bb. Pan -Original Message- From: Robin Dapp Sent: Tuesday, July 25, 2023 4:38 PM To: Li, Pan2 ; gcc-patches@gcc.gnu.org Cc: rdapp@gmail.com; juzhe.zh...@rivai.ai; kito.ch...@sifive.com; Wang, Yanzhang Subject: Re: [PATCH v7] RISC-V: Support CALL for RVV floating-po

Re: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-25 Thread Robin Dapp via Gcc-patches
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 n

RE: [PATCH v7] RISC-V: Support CALL for RVV floating-point dynamic rounding

2023-07-24 Thread Li, Pan2 via Gcc-patches
Hi Robin, 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