Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-28 Thread Segher Boessenkool
Hi! On Wed, Oct 28, 2020 at 11:13:28AM +, Alex Coplan wrote: > This fails bootstrap since we trigger -Wsign-compare without the cast to > unsigned HOST_WIDE_INT on shift_amt: > > + else if (GET_CODE (inner) == MULT > +&& CONST_INT_P (XEXP (inner, 1)) > +&& pos_rtx == 0 &&

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-28 Thread Alex Coplan via Gcc-patches
On 28/10/2020 09:09, Alex Coplan via Gcc-patches wrote: > On 27/10/2020 17:31, Segher Boessenkool wrote: > > On Tue, Oct 27, 2020 at 10:35:59AM +, Alex Coplan wrote: > > > On 26/10/2020 12:43, Segher Boessenkool wrote: > > > > I do not like handling both mult and ashift in one case like this,

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-28 Thread Alex Coplan via Gcc-patches
On 27/10/2020 17:31, Segher Boessenkool wrote: > On Tue, Oct 27, 2020 at 10:35:59AM +, Alex Coplan wrote: > > On 26/10/2020 12:43, Segher Boessenkool wrote: > > > I do not like handling both mult and ashift in one case like this, it > > > complicates things for no good reason. Write it as two

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-27 Thread Segher Boessenkool
On Tue, Oct 27, 2020 at 10:35:59AM +, Alex Coplan wrote: > On 26/10/2020 12:43, Segher Boessenkool wrote: > > I do not like handling both mult and ashift in one case like this, it > > complicates things for no good reason. Write it as two cases, and it > > should be good. > > OK, the

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-27 Thread Alex Coplan via Gcc-patches
On 27/10/2020 10:35, Alex Coplan via Gcc-patches wrote: > On 26/10/2020 12:43, Segher Boessenkool wrote: > > I do not like handling both mult and ashift in one case like this, it > > complicates things for no good reason. Write it as two cases, and it > > should be good. > > OK, the attached

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-27 Thread Alex Coplan via Gcc-patches
On 26/10/2020 12:43, Segher Boessenkool wrote: > On Mon, Oct 26, 2020 at 01:28:42PM +, Alex Coplan wrote: > > On 26/10/2020 07:12, Segher Boessenkool wrote: > > > On Thu, Oct 15, 2020 at 09:59:24AM +0100, Alex Coplan wrote: > > > Can you instead replace the mult by a shift somewhere earlier in

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-26 Thread Segher Boessenkool
On Mon, Oct 26, 2020 at 01:18:54PM +, Alex Coplan wrote: > - else if (GET_CODE (inner) == ASHIFT > + else if ((GET_CODE (inner) == ASHIFT || GET_CODE (inner) == MULT) As I wrote in the other mail, write this as two cases. Write something in the comment for the mult one that this is for the

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-26 Thread Segher Boessenkool
On Mon, Oct 26, 2020 at 01:28:42PM +, Alex Coplan wrote: > On 26/10/2020 07:12, Segher Boessenkool wrote: > > On Thu, Oct 15, 2020 at 09:59:24AM +0100, Alex Coplan wrote: > > Can you instead replace the mult by a shift somewhere earlier in > > make_extract? That would make a lot more sense

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-26 Thread Alex Coplan via Gcc-patches
On 26/10/2020 07:12, Segher Boessenkool wrote: > Hi! > > On Thu, Oct 15, 2020 at 09:59:24AM +0100, Alex Coplan wrote: > > @@ -7650,20 +7650,27 @@ make_extraction (machine_mode mode, rtx inner, > > HOST_WIDE_INT pos, > > is_mode = GET_MODE (SUBREG_REG (inner)); > >inner = SUBREG_REG

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-26 Thread Alex Coplan via Gcc-patches
On 26/10/2020 06:51, Segher Boessenkool wrote: > On Mon, Oct 26, 2020 at 11:06:22AM +, Alex Coplan wrote: > > Well, only the low 32 bits of the subreg are valid. But because those > > low 32 bits are shifted left 2 times, the low 34 bits of the ashift are > > valid: the bottom 2 bits of the

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-26 Thread Segher Boessenkool
Hi! On Thu, Oct 15, 2020 at 09:59:24AM +0100, Alex Coplan wrote: > @@ -7650,20 +7650,27 @@ make_extraction (machine_mode mode, rtx inner, > HOST_WIDE_INT pos, > is_mode = GET_MODE (SUBREG_REG (inner)); >inner = SUBREG_REG (inner); > } > + else if ((GET_CODE (inner) == ASHIFT

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-26 Thread Segher Boessenkool
On Mon, Oct 26, 2020 at 11:06:22AM +, Alex Coplan wrote: > Well, only the low 32 bits of the subreg are valid. But because those > low 32 bits are shifted left 2 times, the low 34 bits of the ashift are > valid: the bottom 2 bits of the ashift are zeros, and the 32 bits above > those are from

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-26 Thread Alex Coplan via Gcc-patches
On 26/10/2020 11:06, Alex Coplan via Gcc-patches wrote: > Well, only the low 32 bits of the subreg are valid. But because those > low 32 bits are shifted left 2 times, the low 34 bits of the ashift are > valid: the bottom 2 bits of the ashift are zeros, and the 32 bits above > those are from the

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-26 Thread Alex Coplan via Gcc-patches
On 26/10/2020 05:48, Segher Boessenkool wrote: > Hi! > > On Mon, Oct 26, 2020 at 10:09:41AM +, Alex Coplan wrote: > > On 22/10/2020 15:39, Segher Boessenkool wrote: > > > On Thu, Oct 15, 2020 at 09:59:24AM +0100, Alex Coplan wrote: > > > > Currently, make_extraction() identifies where we can

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-26 Thread Segher Boessenkool
Hi! On Mon, Oct 26, 2020 at 10:09:41AM +, Alex Coplan wrote: > On 22/10/2020 15:39, Segher Boessenkool wrote: > > On Thu, Oct 15, 2020 at 09:59:24AM +0100, Alex Coplan wrote: > > > Currently, make_extraction() identifies where we can emit an ASHIFT of > > > an extend in place of an

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-26 Thread Alex Coplan via Gcc-patches
Hi Segher, On 22/10/2020 15:39, Segher Boessenkool wrote: > On Thu, Oct 15, 2020 at 09:59:24AM +0100, Alex Coplan wrote: > > Currently, make_extraction() identifies where we can emit an ASHIFT of > > an extend in place of an extraction, but fails to make the corresponding > >

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-25 Thread Segher Boessenkool
Hi! On Thu, Oct 15, 2020 at 09:59:24AM +0100, Alex Coplan wrote: > This patch remedies this situation: after the patch, make_extraction() > now also identifies RTXs such as: > > (mult:DI (subreg:DI (reg:SI r)) (const_int 2^n)) > > and rewrites this as: > > (mult:DI (sign_extend:DI (reg:SI r))

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-22 Thread Segher Boessenkool
On Thu, Oct 15, 2020 at 09:59:24AM +0100, Alex Coplan wrote: > Currently, make_extraction() identifies where we can emit an ASHIFT of > an extend in place of an extraction, but fails to make the corresponding > canonicalization/simplification when presented with a MULT by a power of > two. Such a

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-22 Thread Segher Boessenkool
Hi Alex, On Thu, Oct 22, 2020 at 09:36:02AM +0100, Alex Coplan wrote: > Ping. > > Hopefully this is easier to review/test now that we fix the AArch64 bug first > and deliberately regress code quality so that the impact of the combine patch > can be measured. Yes, I am just busy. I'll get to it

Re: [PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-22 Thread Alex Coplan via Gcc-patches
Ping. Hopefully this is easier to review/test now that we fix the AArch64 bug first and deliberately regress code quality so that the impact of the combine patch can be measured. On 15/10/2020 09:59, Alex Coplan via Gcc-patches wrote: > Currently, make_extraction() identifies where we can emit

[PATCH 2/2] combine: Don't turn (mult (extend x) 2^n) into extract

2020-10-15 Thread Alex Coplan via Gcc-patches
Currently, make_extraction() identifies where we can emit an ASHIFT of an extend in place of an extraction, but fails to make the corresponding canonicalization/simplification when presented with a MULT by a power of two. Such a representation is canonical when representing a left-shifted address