Clobber REG_CC only for some constraint alternatives?

2020-08-14 Thread Senthil Kumar Selvaraj via Gcc
Hi, I'm working on porting AVR to MODE_CC, and there are quite a few patterns that clobber the condition code reg only for certain constraint alternatives. For e.g., (define_insn "mov_insn" [(set (match_operand:ALL1 0 "nonimmediate_operand" "=r,d,Qm ,r ,q,r,*r") (match_

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-14 Thread Matt Wette via Gcc
On 8/14/20 4:16 AM, Senthil Kumar Selvaraj via Gcc wrote: Hi, I'm working on porting AVR to MODE_CC, and there are quite a few patterns that clobber the condition code reg only for certain constraint alternatives. For e.g., (define_insn "mov_insn" [(set (match_operand:ALL1 0 "nonimm

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-14 Thread Segher Boessenkool
Hi! On Fri, Aug 14, 2020 at 04:46:59PM +0530, Senthil Kumar Selvaraj via Gcc wrote: > I'm working on porting AVR to MODE_CC, I'm very happy to see people work on that. > (define_insn "*mov_insn_noclobber_flags" > [(set (match_operand:ALL1 0 "nonimmediate_operand" "=r,d ,q,r") > (ma

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-14 Thread Pip Cet via Gcc
On Fri, Aug 14, 2020 at 3:33 PM Matt Wette via Gcc wrote: > Happy to see someone working this. Are you starting with one CC mode? I'm also working on this (mostly at bug#92792), and so far am using two modes: the general reg:CC mode for proper comparison insns, and CCNZ for optimization in the

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-14 Thread Pip Cet via Gcc
On Fri, Aug 14, 2020 at 4:24 PM Segher Boessenkool wrote: > On Fri, Aug 14, 2020 at 04:46:59PM +0530, Senthil Kumar Selvaraj via Gcc > wrote: > > (define_insn "*mov_insn_noclobber_flags" > > [(set (match_operand:ALL1 0 "nonimmediate_operand" "=r,d ,q,r") > > (match_operand:ALL1 1 "nox

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-14 Thread Segher Boessenkool
Hi! On Fri, Aug 14, 2020 at 05:47:02PM +, Pip Cet wrote: > On Fri, Aug 14, 2020 at 4:24 PM Segher Boessenkool > wrote: > > On Fri, Aug 14, 2020 at 04:46:59PM +0530, Senthil Kumar Selvaraj via Gcc > > wrote: > > > (define_insn "*mov_insn_noclobber_flags" > > > [(set (match_operand:ALL1 0 "n

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-15 Thread Pip Cet via Gcc
On Sat, Aug 15, 2020 at 12:30 AM Segher Boessenkool wrote: > On Fri, Aug 14, 2020 at 05:47:02PM +, Pip Cet wrote: > > On Fri, Aug 14, 2020 at 4:24 PM Segher Boessenkool > > wrote: > > > If you want to say some alternative does not clobber anything, just use > > > the constraint "X" for that a

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-15 Thread Segher Boessenkool
On Sat, Aug 15, 2020 at 10:18:27AM +, Pip Cet wrote: > > > What I'm currently doing is this: > > > > > > (define_split > > > [(set (match_operand 0 "nonimmediate_operand") > > > (match_operand 1 "nox_general_operand"))] > > > "reload_completed && mov_clobbers_cc (insn, operands)" > > >

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-15 Thread Hans-Peter Nilsson
On Fri, 14 Aug 2020, Senthil Kumar Selvaraj via Gcc wrote: > As you can deduce from the (set_attr "cc" ..), only constraint > alternatives 0,2,3 and 6 clobber CC - others leave it unchanged. Yes, I recognize that. > My first version of the port adds a post-reload splitter that adds a > (clobber (

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-16 Thread Pip Cet via Gcc
On Sun, Aug 16, 2020 at 12:50 AM Segher Boessenkool wrote: > On Sat, Aug 15, 2020 at 10:18:27AM +, Pip Cet wrote: > > > > What I'm currently doing is this: > > > > > > > > (define_split > > > > [(set (match_operand 0 "nonimmediate_operand") > > > > (match_operand 1 "nox_general_operand")

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-17 Thread Senthil Kumar Selvaraj via Gcc
Pip Cet writes: > On Sun, Aug 16, 2020 at 12:50 AM Segher Boessenkool > wrote: >> On Sat, Aug 15, 2020 at 10:18:27AM +, Pip Cet wrote: >> > > > What I'm currently doing is this: >> > > > >> > > > (define_split >> > > > [(set (match_operand 0 "nonimmediate_operand") >> > > > (match_ope

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-17 Thread Pip Cet via Gcc
On Mon, Aug 17, 2020 at 7:31 AM Senthil Kumar Selvaraj wrote: > > (define_split > > [(parallel [(set (match_operand:ALL1 0 "nonimmediate_operand") > > (match_operand:ALL1 1 "nox_general_operand")) > > (clobber (reg:CC REG_CC))])] > > "reload_completed && REG_P (operands[

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-17 Thread Jeff Law via Gcc
On Fri, 2020-08-14 at 16:46 +0530, Senthil Kumar Selvaraj wrote: > Hi, > > I'm working on porting AVR to MODE_CC, and there are quite a few > patterns that clobber the condition code reg only for certain > constraint alternatives. For e.g., Yea. H8 has the same issue. It's worth noting tha

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-17 Thread Segher Boessenkool
Hi! On Sun, Aug 16, 2020 at 06:28:44PM +, Pip Cet wrote: > > > IIUC, the idea is that references to REG_CC, except for clobbers, are > > > only introduced in the post-reload split pass, so it cannot be live > > > before our define_split runs. Does that make sense? > > > > Yes, it does. It has

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-17 Thread Senthil Kumar Selvaraj via Gcc
Pip Cet writes: > On Mon, Aug 17, 2020 at 7:31 AM Senthil Kumar Selvaraj > wrote: >> > (define_split >> > [(parallel [(set (match_operand:ALL1 0 "nonimmediate_operand") >> > (match_operand:ALL1 1 "nox_general_operand")) >> > (clobber (reg:CC REG_CC))])] >> > "reload_c

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-18 Thread Hans-Peter Nilsson
On Sun, 16 Aug 2020, Pip Cet via Gcc wrote: > For example, here's what I currently have: > > (define_expand "mov" > [(parallel [(set (match_operand:MOVMODE 0 "nonimmediate_operand" "") >(match_operand:MOVMODE 1 "general_operand" "")) > (clobber (reg:CC REG_CC))])] > ...)

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-18 Thread Senthil Kumar Selvaraj via Gcc
Hans-Peter Nilsson writes: > On Fri, 14 Aug 2020, Senthil Kumar Selvaraj via Gcc wrote: >> As you can deduce from the (set_attr "cc" ..), only constraint >> alternatives 0,2,3 and 6 clobber CC - others leave it unchanged. > > Yes, I recognize that. > >> My first version of the port adds a post-r

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-19 Thread Hans-Peter Nilsson
On Wed, 19 Aug 2020, Senthil Kumar Selvaraj wrote: > > Hans-Peter Nilsson writes: > > > On Fri, 14 Aug 2020, Senthil Kumar Selvaraj via Gcc wrote: > >> As you can deduce from the (set_attr "cc" ..), only constraint > >> alternatives 0,2,3 and 6 clobber CC - others leave it unchanged. > > > > Yes, I

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-19 Thread Senthil Kumar Selvaraj via Gcc
Hans-Peter Nilsson writes: > On Wed, 19 Aug 2020, Senthil Kumar Selvaraj wrote: >> >> Hans-Peter Nilsson writes: >> >> > On Fri, 14 Aug 2020, Senthil Kumar Selvaraj via Gcc wrote: >> >> As you can deduce from the (set_attr "cc" ..), only constraint >> >> alternatives 0,2,3 and 6 clobber CC - oth

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-20 Thread Andrew Stubbs
On 20/08/2020 06:40, Senthil Kumar Selvaraj via Gcc wrote: What I didn't understand was the (set-attr "cc") part - as far I can tell, this results in (set_attr "cc_enabled" ...) in all of the three substituted patterns, so I wondered why not just have (set_attr "cc_enabled" ...) in the original d

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-20 Thread H.J. Lu via Gcc
On Thu, Aug 20, 2020 at 1:53 AM Andrew Stubbs wrote: > > On 20/08/2020 06:40, Senthil Kumar Selvaraj via Gcc wrote: > > What I didn't understand was the (set-attr "cc") > > part - as far I can tell, this results in (set_attr "cc_enabled" ...) in > > all of the three substituted patterns, so I wond

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-20 Thread Pip Cet via Gcc
On Tue, Aug 18, 2020 at 6:52 AM Senthil Kumar Selvaraj wrote: > > recognize such insns, but as it stands that define_insn would > > recognize the incorrect insn: > > > > [(set (reg:QI 0) (const_int 0)) > > (clobber (scratch:CC))] > > get_cc_reg_clobber_rtx also looks at the insn itself (i.e. what

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-20 Thread Senthil Kumar Selvaraj via Gcc
Pip Cet writes: > On Tue, Aug 18, 2020 at 6:52 AM Senthil Kumar Selvaraj > wrote: >> > recognize such insns, but as it stands that define_insn would >> > recognize the incorrect insn: >> > >> > [(set (reg:QI 0) (const_int 0)) >> > (clobber (scratch:CC))] >> >> get_cc_reg_clobber_rtx also looks

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-20 Thread Hans-Peter Nilsson
On Thu, 20 Aug 2020, Senthil Kumar Selvaraj wrote: > What I didn't understand was the (set-attr "cc") > part - as far I can tell, this results in (set_attr "cc_enabled" ...) in > all of the three substituted patterns, so I wondered why not just have > (set_attr "cc_enabled" ...) in the original de

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-24 Thread Jeff Law via Gcc
On Thu, 2020-08-20 at 21:36 +0530, Senthil Kumar Selvaraj via Gcc wrote: > Pip Cet writes: > > > On Tue, Aug 18, 2020 at 6:52 AM Senthil Kumar Selvaraj > > wrote: > > > > recognize such insns, but as it stands that define_insn would > > > > recognize the incorrect insn: > > > > > > > > [(set (re

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-25 Thread Hans-Peter Nilsson
On Mon, 24 Aug 2020, Jeff Law via Gcc wrote: > On Thu, 2020-08-20 at 21:36 +0530, Senthil Kumar Selvaraj via Gcc wrote: > > The post-reload splitter introduces the clobber. The wiki > > suggests that approach if most insns clobber REG_CC, perhaps because of > > the missed optimizations you describe

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-26 Thread Pip Cet via Gcc
On Mon, Aug 24, 2020 at 6:18 PM Jeff Law wrote: > > The post-reload splitter introduces the clobber. The wiki > > suggests that approach if most insns clobber REG_CC, perhaps because of > > the missed optimizations you describe below? > If most patterns set/clobber the flags, then yes, it's slight

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-26 Thread Jeff Law via Gcc
On Tue, 2020-08-25 at 23:58 -0400, Hans-Peter Nilsson wrote: > On Mon, 24 Aug 2020, Jeff Law via Gcc wrote: > > On Thu, 2020-08-20 at 21:36 +0530, Senthil Kumar Selvaraj via Gcc wrote: > > > The post-reload splitter introduces the clobber. The wiki > > > suggests that approach if most insns clobber

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-26 Thread Jeff Law via Gcc
On Wed, 2020-08-26 at 11:18 +, Pip Cet wrote: > On Mon, Aug 24, 2020 at 6:18 PM Jeff Law wrote: > > > The post-reload splitter introduces the clobber. The wiki > > > suggests that approach if most insns clobber REG_CC, perhaps because of > > > the missed optimizations you describe below? > > I

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-26 Thread Hans-Peter Nilsson
On Wed, 26 Aug 2020, Jeff Law wrote: > On Tue, 2020-08-25 at 23:58 -0400, Hans-Peter Nilsson wrote: > > On Mon, 24 Aug 2020, Jeff Law via Gcc wrote: > > > On Thu, 2020-08-20 at 21:36 +0530, Senthil Kumar Selvaraj via Gcc wrote: > > > > The post-reload splitter introduces the clobber. The wiki > >

Re: Clobber REG_CC only for some constraint alternatives?

2020-08-27 Thread Jeff Law via Gcc
On Thu, 2020-08-27 at 16:31 +0530, Senthil Kumar Selvaraj wrote: > Pip Cet writes: > > > On Mon, Aug 24, 2020 at 6:18 PM Jeff Law wrote: > > > > The post-reload splitter introduces the clobber. The wiki > > > > suggests that approach if most insns clobber REG_CC, perhaps because of > > > > the mi

Re: Clobber REG_CC only for some constraint alternatives?

2020-09-01 Thread Hans-Peter Nilsson
On Wed, 26 Aug 2020, Pip Cet via Gcc wrote: > Note that whether there is a CC-setting variant depends not just on > the "cc" attr, but also on the precise operands for some values of the > "cc" attr, which requires hairy C code to figure out. > > Is it possible to avoid this situation by avoiding