Re: [PATCH] Check if loading const from mem is faster

2022-03-10 Thread Jiufu Guo via Gcc-patches
Hi! Richard Biener writes: > On Thu, 10 Mar 2022, Jiufu Guo wrote: > >> >> Hi! >> >> Richard Biener writes: >> >> > On Wed, 9 Mar 2022, Jiufu Guo wrote: >> > >> >> >> >> Hi! >> >> >> >> Richard Biener writes: >> >> >> >> > On Tue, 8 Mar 2022, Jiufu Guo wrote: >> >> > >> >> >> Jiufu

Re: [PATCH] Check if loading const from mem is faster

2022-03-09 Thread Richard Biener via Gcc-patches
On Thu, 10 Mar 2022, Jiufu Guo wrote: > > Hi! > > Richard Biener writes: > > > On Wed, 9 Mar 2022, Jiufu Guo wrote: > > > >> > >> Hi! > >> > >> Richard Biener writes: > >> > >> > On Tue, 8 Mar 2022, Jiufu Guo wrote: > >> > > >> >> Jiufu Guo writes: > >> >> > >> >> Hi! > >> >> > >> >> >

Re: [PATCH] Check if loading const from mem is faster

2022-03-09 Thread Jiufu Guo via Gcc-patches
Hi! Richard Biener writes: > On Wed, 9 Mar 2022, Jiufu Guo wrote: > >> >> Hi! >> >> Richard Biener writes: >> >> > On Tue, 8 Mar 2022, Jiufu Guo wrote: >> > >> >> Jiufu Guo writes: >> >> >> >> Hi! >> >> >> >> > Hi Sehger, >> >> > >> >> > Segher Boessenkool writes: >> >> > >> >> >> On

Re: [PATCH] Check if loading const from mem is faster

2022-03-08 Thread Richard Biener via Gcc-patches
On Wed, 9 Mar 2022, Jiufu Guo wrote: > > Hi! > > Richard Biener writes: > > > On Tue, 8 Mar 2022, Jiufu Guo wrote: > > > >> Jiufu Guo writes: > >> > >> Hi! > >> > >> > Hi Sehger, > >> > > >> > Segher Boessenkool writes: > >> > > >> >> On Tue, Mar 01, 2022 at 10:28:57PM +0800, Jiufu Guo

Re: [PATCH] Check if loading const from mem is faster

2022-03-08 Thread Jiufu Guo via Gcc-patches
Hi! Richard Biener writes: > On Tue, 8 Mar 2022, Jiufu Guo wrote: > >> Jiufu Guo writes: >> >> Hi! >> >> > Hi Sehger, >> > >> > Segher Boessenkool writes: >> > >> >> On Tue, Mar 01, 2022 at 10:28:57PM +0800, Jiufu Guo wrote: >> >>> Segher Boessenkool writes: >> >>> > No. insn_cost is

Re: [PATCH] Check if loading const from mem is faster

2022-03-08 Thread Richard Biener via Gcc-patches
On Tue, 8 Mar 2022, Jiufu Guo wrote: > Jiufu Guo writes: > > Hi! > > > Hi Sehger, > > > > Segher Boessenkool writes: > > > >> On Tue, Mar 01, 2022 at 10:28:57PM +0800, Jiufu Guo wrote: > >>> Segher Boessenkool writes: > >>> > No. insn_cost is only for correct, existing instructions, not for

Re: [PATCH] Check if loading const from mem is faster

2022-03-08 Thread Jiufu Guo via Gcc-patches
Jiufu Guo writes: Hi! > Hi Sehger, > > Segher Boessenkool writes: > >> On Tue, Mar 01, 2022 at 10:28:57PM +0800, Jiufu Guo wrote: >>> Segher Boessenkool writes: >>> > No. insn_cost is only for correct, existing instructions, not for >>> > made-up nonsense. I created insn_cost precisely to

Re: [PATCH] Check if loading const from mem is faster

2022-03-03 Thread Jiufu Guo via Gcc-patches
Hi Sehger, Segher Boessenkool writes: > On Tue, Mar 01, 2022 at 10:28:57PM +0800, Jiufu Guo wrote: >> Segher Boessenkool writes: >> > No. insn_cost is only for correct, existing instructions, not for >> > made-up nonsense. I created insn_cost precisely to get away from that >> > aspect of

Re: [PATCH] Check if loading const from mem is faster

2022-03-03 Thread Jiufu Guo via Gcc-patches
Hi, Jeff Law writes: > On 3/1/2022 12:47 AM, Richard Biener via Gcc-patches wrote: >> On Tue, 1 Mar 2022, Jiufu Guo wrote: >> >>> Segher Boessenkool writes: >>> On Thu, Feb 24, 2022 at 09:50:28AM +0100, Richard Biener wrote: > On Thu, 24 Feb 2022, Jiufu Guo wrote: >> And another

Re: [PATCH] Check if loading const from mem is faster

2022-03-02 Thread Segher Boessenkool
On Tue, Mar 01, 2022 at 10:28:57PM +0800, Jiufu Guo wrote: > Segher Boessenkool writes: > > No. insn_cost is only for correct, existing instructions, not for > > made-up nonsense. I created insn_cost precisely to get away from that > > aspect of rtx_cost (and some other issues, like, it is

Re: [PATCH] Check if loading const from mem is faster

2022-03-02 Thread Jeff Law via Gcc-patches
On 3/1/2022 12:47 AM, Richard Biener via Gcc-patches wrote: On Tue, 1 Mar 2022, Jiufu Guo wrote: Segher Boessenkool writes: On Thu, Feb 24, 2022 at 09:50:28AM +0100, Richard Biener wrote: On Thu, 24 Feb 2022, Jiufu Guo wrote: And another thing as Segher pointed out, CSE is doing too

Re: [PATCH] Check if loading const from mem is faster

2022-03-01 Thread Jiufu Guo via Gcc-patches
Segher Boessenkool writes: Hi! > Hi! > > On Thu, Feb 24, 2022 at 03:48:54PM +0800, Jiufu Guo wrote: >> Segher Boessenkool writes: >> > That is the problem yes. You need insns to call insn_cost on. You can >> > look in combine.c:combine_validate_cost to see how this can be done; but >> > you

Re: [PATCH] Check if loading const from mem is faster

2022-03-01 Thread Jiufu Guo via Gcc-patches
Richard Biener writes: > On Tue, 1 Mar 2022, Jiufu Guo wrote: > >> Segher Boessenkool writes: >> >> > On Thu, Feb 24, 2022 at 09:50:28AM +0100, Richard Biener wrote: >> >> On Thu, 24 Feb 2022, Jiufu Guo wrote: >> >> > And another thing as Segher pointed out, CSE is doing too >> >> > much work.

Re: [PATCH] Check if loading const from mem is faster

2022-02-28 Thread Richard Biener via Gcc-patches
On Tue, 1 Mar 2022, Jiufu Guo wrote: > Segher Boessenkool writes: > > > On Thu, Feb 24, 2022 at 09:50:28AM +0100, Richard Biener wrote: > >> On Thu, 24 Feb 2022, Jiufu Guo wrote: > >> > And another thing as Segher pointed out, CSE is doing too > >> > much work. It may be ok to separate the

Re: [PATCH] Check if loading const from mem is faster

2022-02-28 Thread Jiufu Guo via Gcc-patches
Segher Boessenkool writes: > On Thu, Feb 24, 2022 at 09:50:28AM +0100, Richard Biener wrote: >> On Thu, 24 Feb 2022, Jiufu Guo wrote: >> > And another thing as Segher pointed out, CSE is doing too >> > much work. It may be ok to separate the constant handling >> > logic from CSE. >> >> Not

Re: [PATCH] Check if loading const from mem is faster

2022-02-28 Thread Segher Boessenkool
On Thu, Feb 24, 2022 at 09:50:28AM +0100, Richard Biener wrote: > On Thu, 24 Feb 2022, Jiufu Guo wrote: > > And another thing as Segher pointed out, CSE is doing too > > much work. It may be ok to separate the constant handling > > logic from CSE. > > Not sure - CSE just is value numbering, I

Re: [PATCH] Check if loading const from mem is faster

2022-02-28 Thread Segher Boessenkool
Hi! On Thu, Feb 24, 2022 at 03:48:54PM +0800, Jiufu Guo wrote: > Segher Boessenkool writes: > > That is the problem yes. You need insns to call insn_cost on. You can > > look in combine.c:combine_validate_cost to see how this can be done; but > > you need to have some code to generate in the

Re: [PATCH] Check if loading const from mem is faster

2022-02-28 Thread Jiufu Guo via Gcc-patches
Richard Biener writes: > On Fri, 25 Feb 2022, Jiufu Guo wrote: > >> Richard Biener writes: >> >> > On Fri, 25 Feb 2022, Jiufu Guo wrote: >> > >> >> Richard Biener writes: >> >> >> >> > On Thu, 24 Feb 2022, Jiufu Guo wrote: >> >> > >> >> >> Jiufu Guo via Gcc-patches writes: >> >> >> >> >>

Re: [PATCH] Check if loading const from mem is faster

2022-02-25 Thread Richard Biener via Gcc-patches
On Fri, 25 Feb 2022, Jiufu Guo wrote: > Richard Biener writes: > > > On Fri, 25 Feb 2022, Jiufu Guo wrote: > > > >> Richard Biener writes: > >> > >> > On Thu, 24 Feb 2022, Jiufu Guo wrote: > >> > > >> >> Jiufu Guo via Gcc-patches writes: > >> >> > >> >> > Segher Boessenkool writes: > >> >>

Re: [PATCH] Check if loading const from mem is faster

2022-02-25 Thread Jiufu Guo via Gcc-patches
Richard Biener writes: > On Fri, 25 Feb 2022, Jiufu Guo wrote: > >> Richard Biener writes: >> >> > On Thu, 24 Feb 2022, Jiufu Guo wrote: >> > >> >> Jiufu Guo via Gcc-patches writes: >> >> >> >> > Segher Boessenkool writes: >> >> > >> >> >> On Wed, Feb 23, 2022 at 02:02:59PM +0100, Richard

Re: [PATCH] Check if loading const from mem is faster

2022-02-25 Thread Richard Biener via Gcc-patches
On Fri, 25 Feb 2022, Jiufu Guo wrote: > Richard Biener writes: > > > On Thu, 24 Feb 2022, Jiufu Guo wrote: > > > >> Jiufu Guo via Gcc-patches writes: > >> > >> > Segher Boessenkool writes: > >> > > >> >> On Wed, Feb 23, 2022 at 02:02:59PM +0100, Richard Biener wrote: > >> >>> I'm assuming

Re: [PATCH] Check if loading const from mem is faster

2022-02-24 Thread Jiufu Guo via Gcc-patches
Richard Biener writes: > On Thu, 24 Feb 2022, Jiufu Guo wrote: > >> Jiufu Guo via Gcc-patches writes: >> >> > Segher Boessenkool writes: >> > >> >> On Wed, Feb 23, 2022 at 02:02:59PM +0100, Richard Biener wrote: >> >>> I'm assuming we're always dealing with >> >>> >> >>> (set (reg:MODE ..)

Re: [PATCH] Check if loading const from mem is faster

2022-02-24 Thread Richard Biener via Gcc-patches
On Thu, 24 Feb 2022, Jiufu Guo wrote: > Jiufu Guo via Gcc-patches writes: > > > Segher Boessenkool writes: > > > >> On Wed, Feb 23, 2022 at 02:02:59PM +0100, Richard Biener wrote: > >>> I'm assuming we're always dealing with > >>> > >>> (set (reg:MODE ..) ) > >>> > >>> here and CSE is not

Re: [PATCH] Check if loading const from mem is faster

2022-02-23 Thread Jiufu Guo via Gcc-patches
Segher Boessenkool writes: > On Wed, Feb 23, 2022 at 07:32:55PM +0800, guojiufu wrote: >> >We already have TARGET_INSN_COST which you could ask for a cost. >> >Like if we'd have a single_set then just temporarily substitute >> >the RHS with the candidate and cost the insns and compare against >>

Re: [PATCH] Check if loading const from mem is faster

2022-02-23 Thread Jiufu Guo via Gcc-patches
Jiufu Guo via Gcc-patches writes: > Segher Boessenkool writes: > >> On Wed, Feb 23, 2022 at 02:02:59PM +0100, Richard Biener wrote: >>> I'm assuming we're always dealing with >>> >>> (set (reg:MODE ..) ) >>> >>> here and CSE is not substituting into random places of an >>> instruction(?).

Re: [PATCH] Check if loading const from mem is faster

2022-02-23 Thread Jiufu Guo via Gcc-patches
Segher Boessenkool writes: > On Wed, Feb 23, 2022 at 02:02:59PM +0100, Richard Biener wrote: >> I'm assuming we're always dealing with >> >> (set (reg:MODE ..) ) >> >> here and CSE is not substituting into random places of an >> instruction(?). I don't know what 'rtx_cost' should evaluate

Re: [PATCH] Check if loading const from mem is faster

2022-02-23 Thread Segher Boessenkool
On Wed, Feb 23, 2022 at 07:32:55PM +0800, guojiufu wrote: > >We already have TARGET_INSN_COST which you could ask for a cost. > >Like if we'd have a single_set then just temporarily substitute > >the RHS with the candidate and cost the insns and compare against > >the original insn cost. So why

Re: [PATCH] Check if loading const from mem is faster

2022-02-23 Thread Segher Boessenkool
On Wed, Feb 23, 2022 at 02:02:59PM +0100, Richard Biener wrote: > I'm assuming we're always dealing with > > (set (reg:MODE ..) ) > > here and CSE is not substituting into random places of an > instruction(?). I don't know what 'rtx_cost' should evaluate > to for a constant, if it should

Re: [PATCH] Check if loading const from mem is faster

2022-02-23 Thread Richard Biener via Gcc-patches
On Wed, 23 Feb 2022, guojiufu wrote: > > > On 2/22/22 PM3:26, Richard Biener wrote: > > On Tue, 22 Feb 2022, Jiufu Guo wrote: > > > >> Hi, > >> > >> For constants, there are some codes to check: if it is able to put > >> to instruction as an immediate operand or it is profitable to load from >

Re: [PATCH] Check if loading const from mem is faster

2022-02-23 Thread guojiufu via Gcc-patches
On 2/22/22 PM3:26, Richard Biener wrote: On Tue, 22 Feb 2022, Jiufu Guo wrote: Hi, For constants, there are some codes to check: if it is able to put to instruction as an immediate operand or it is profitable to load from mem. There are still some places that could be improved for

Re: [PATCH] Check if loading const from mem is faster

2022-02-22 Thread guojiufu via Gcc-patches
On 2022-02-23 01:30, Segher Boessenkool wrote: Hi Jiu Fu, On Tue, Feb 22, 2022 at 02:53:13PM +0800, Jiufu Guo wrote: static bool rs6000_cannot_force_const_mem (machine_mode mode ATTRIBUTE_UNUSED, rtx x) { - if (GET_CODE (x) == HIGH - && GET_CODE (XEXP (x, 0)) == UNSPEC) + if

Re: [PATCH] Check if loading const from mem is faster

2022-02-22 Thread Segher Boessenkool
Hi Jiu Fu, On Tue, Feb 22, 2022 at 02:53:13PM +0800, Jiufu Guo wrote: > static bool > rs6000_cannot_force_const_mem (machine_mode mode ATTRIBUTE_UNUSED, rtx x) > { > - if (GET_CODE (x) == HIGH > - && GET_CODE (XEXP (x, 0)) == UNSPEC) > + if (GET_CODE (x) == HIGH) > return true;

Re: [PATCH] Check if loading const from mem is faster

2022-02-21 Thread Richard Biener via Gcc-patches
On Tue, 22 Feb 2022, Jiufu Guo wrote: > Hi, > > For constants, there are some codes to check: if it is able to put > to instruction as an immediate operand or it is profitable to load from > mem. There are still some places that could be improved for platforms. > > This patch could handle

[PATCH] Check if loading const from mem is faster

2022-02-21 Thread Jiufu Guo via Gcc-patches
Hi, For constants, there are some codes to check: if it is able to put to instruction as an immediate operand or it is profitable to load from mem. There are still some places that could be improved for platforms. This patch could handle PR63281/57836. This patch does not change too much on