Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-12-21 Thread YunQiang Su
> > > >> (insn 20 19 23 2 (set (reg/v:DI 200 [ val+-4 ]) > >> (sign_extend:DI (subreg:SI (reg/v:DI 200 [ val+-4 ]) 4))) > >> "/app/example.cpp":7:29 -1 > >> (nil)) > > Haven't had chance to compile and look at it properly, but this subreg > seems suspicious for MIPS, given the

Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-12-21 Thread YunQiang Su
> > Note I think Andrews comment#7 in the PR is spot-on then, the issue > isn't the bitfield inserts but the compare where combine elides > the sign_extend in favor of a subreg. That's likely some wrongdoing > in simplify-rtx in the context of WORD_REGISTER_OPERATIONS. > Yes. There are 2

Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-07-20 Thread Richard Sandiford via Gcc-patches
Richard Biener writes: #> On Thu, 20 Jul 2023, Richard Sandiford wrote: > >> Jeff Law via Gcc-patches writes: >> > On 7/19/23 04:25, Richard Biener wrote: >> >> On Wed, 19 Jul 2023, YunQiang Su wrote: >> >> >> >>> Eric Botcazou ?2023?7?19??? 17:45??? >> >> > I don't see that. That's

Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-07-20 Thread Richard Biener via Gcc-patches
On Thu, 20 Jul 2023, Richard Sandiford wrote: > Jeff Law via Gcc-patches writes: > > On 7/19/23 04:25, Richard Biener wrote: > >> On Wed, 19 Jul 2023, YunQiang Su wrote: > >> > >>> Eric Botcazou ?2023?7?19??? 17:45??? > > > I don't see that. That's definitely not what GCC expects

Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-07-20 Thread Richard Sandiford via Gcc-patches
Jeff Law via Gcc-patches writes: > On 7/19/23 04:25, Richard Biener wrote: >> On Wed, 19 Jul 2023, YunQiang Su wrote: >> >>> Eric Botcazou ?2023?7?19??? 17:45??? > I don't see that. That's definitely not what GCC expects here, > the left-most word of the doubleword should be

Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-07-19 Thread Jeff Law via Gcc-patches
On 7/19/23 04:25, Richard Biener wrote: On Wed, 19 Jul 2023, YunQiang Su wrote: Eric Botcazou ?2023?7?19??? 17:45??? I don't see that. That's definitely not what GCC expects here, the left-most word of the doubleword should be unchanged. Your testcase should be a dg-do-run and

Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-07-19 Thread Richard Biener via Gcc-patches
On Wed, 19 Jul 2023, YunQiang Su wrote: > Eric Botcazou ?2023?7?19??? 17:45??? > > > > > I don't see that. That's definitely not what GCC expects here, > > > the left-most word of the doubleword should be unchanged. > > > > > > Your testcase should be a dg-do-run and probably more like > > > >

Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-07-19 Thread YunQiang Su via Gcc-patches
Eric Botcazou 于2023年7月19日周三 17:45写道: > > > I don't see that. That's definitely not what GCC expects here, > > the left-most word of the doubleword should be unchanged. > > > > Your testcase should be a dg-do-run and probably more like > > > > NOMIPS16 int __attribute__((noipa)) test (const

Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-07-19 Thread Eric Botcazou via Gcc-patches
> I don't see that. That's definitely not what GCC expects here, > the left-most word of the doubleword should be unchanged. > > Your testcase should be a dg-do-run and probably more like > > NOMIPS16 int __attribute__((noipa)) test (const unsigned char *buf) > { > int val; > ((unsigned

Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-07-19 Thread YunQiang Su via Gcc-patches
Richard Biener 于2023年7月19日周三 17:23写道: > > On Wed, 19 Jul 2023, YunQiang Su wrote: > > > Richard Biener ?2023?7?19??? 15:22??? > > > > > > On Wed, 19 Jul 2023, YunQiang Su wrote: > > > > > > > Richard Biener via Gcc-patches ?2023?7?19??? > > > > 14:27??? > > > > > > > > > > On Wed, 19 Jul 2023,

Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-07-19 Thread Richard Biener via Gcc-patches
On Wed, 19 Jul 2023, Richard Biener wrote: > On Wed, 19 Jul 2023, YunQiang Su wrote: > > > Richard Biener ?2023?7?19??? 15:22??? > > > > > > On Wed, 19 Jul 2023, YunQiang Su wrote: > > > > > > > Richard Biener via Gcc-patches ?2023?7?19??? > > > > 14:27??? > > > > > > > > > > On Wed, 19 Jul

Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-07-19 Thread Richard Biener via Gcc-patches
On Wed, 19 Jul 2023, YunQiang Su wrote: > Richard Biener ?2023?7?19??? 15:22??? > > > > On Wed, 19 Jul 2023, YunQiang Su wrote: > > > > > Richard Biener via Gcc-patches ?2023?7?19??? > > > 14:27??? > > > > > > > > On Wed, 19 Jul 2023, YunQiang Su wrote: > > > > > > > > > PR #104914 > > > > > >

Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-07-19 Thread YunQiang Su via Gcc-patches
I am not sure this patch is best, while I think that I am sure the initial RTL is not correct, the initial RTL of ARM64 is like (insn 8 7 9 2 (set (zero_extract:SI (reg/v:SI 98 [ val ]) ^^ (const_int 8 [0x8]) (const_int 0

Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-07-19 Thread YunQiang Su via Gcc-patches
YunQiang Su 于2023年7月19日周三 16:21写道: > > Richard Biener 于2023年7月19日周三 15:22写道: > > > > On Wed, 19 Jul 2023, YunQiang Su wrote: > > > > > Richard Biener via Gcc-patches ?2023?7?19??? > > > 14:27??? > > > > > > > > On Wed, 19 Jul 2023, YunQiang Su wrote: > > > > > > > > > PR #104914 > > > > > > >

Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-07-19 Thread YunQiang Su via Gcc-patches
Richard Biener 于2023年7月19日周三 15:22写道: > > On Wed, 19 Jul 2023, YunQiang Su wrote: > > > Richard Biener via Gcc-patches ?2023?7?19??? > > 14:27??? > > > > > > On Wed, 19 Jul 2023, YunQiang Su wrote: > > > > > > > PR #104914 > > > > > > > > When work with > > > > int val; > > > > ((unsigned

Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-07-19 Thread Richard Biener via Gcc-patches
On Wed, 19 Jul 2023, YunQiang Su wrote: > Richard Biener via Gcc-patches ?2023?7?19??? > 14:27??? > > > > On Wed, 19 Jul 2023, YunQiang Su wrote: > > > > > PR #104914 > > > > > > When work with > > > int val; > > > ((unsigned char*))[3] = *buf; > > > if (val > 0) ... > > > The RTX mode is

Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-07-19 Thread YunQiang Su via Gcc-patches
Richard Biener via Gcc-patches 于2023年7月19日周三 14:27写道: > > On Wed, 19 Jul 2023, YunQiang Su wrote: > > > PR #104914 > > > > When work with > > int val; > > ((unsigned char*))[3] = *buf; > > if (val > 0) ... > > The RTX mode is obtained from REG instead of SUBREG, which make > > D is used

Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-07-19 Thread Richard Biener via Gcc-patches
On Wed, 19 Jul 2023, YunQiang Su wrote: > PR #104914 > > When work with > int val; > ((unsigned char*))[3] = *buf; > if (val > 0) ... > The RTX mode is obtained from REG instead of SUBREG, which make > D is used instead of . Thus something wrong happens > on sign-extend default

[PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible

2023-07-18 Thread YunQiang Su
PR #104914 When work with int val; ((unsigned char*))[3] = *buf; if (val > 0) ... The RTX mode is obtained from REG instead of SUBREG, which make D is used instead of . Thus something wrong happens on sign-extend default architectures, like MIPS64. Let's use str_rtx and mode of str_rtx as