Re: RFC: Combine of compare & and oddity

2015-09-03 Thread Jeff Law
On 09/03/2015 01:14 PM, Richard Sandiford wrote: If the (and ...) form is a better canonical form (IMO yes) then I think it would be better to make it the canonical form across the baord and update the existing ports to use it. The criteria could be something like no unjustifiable differences i

Re: RFC: Combine of compare & and oddity

2015-09-03 Thread Segher Boessenkool
On Thu, Sep 03, 2015 at 07:53:12PM +0100, Wilco Dijkstra wrote: > > > >>You will end up with a *lot* of target hooks like this. It will also > > > >>make testing harder (less coverage). I am not sure that is a good idea. > > > > > > > >We certainly need a lot more target hooks in general so GCC c

Re: RFC: Combine of compare & and oddity

2015-09-03 Thread Richard Sandiford
Jeff Law writes: > On 09/03/2015 12:53 PM, Wilco Dijkstra wrote: >>> Segher Boessenkool wrote: >>> On Thu, Sep 03, 2015 at 10:09:36AM -0600, Jeff Law wrote: >> You will end up with a *lot* of target hooks like this. It will also >> make testing harder (less coverage). I am not sure that

Re: RFC: Combine of compare & and oddity

2015-09-03 Thread Segher Boessenkool
On Thu, Sep 03, 2015 at 12:42:30PM -0600, Jeff Law wrote: > Note huge parts of combine are structured around the needs of processors > from the late 80s and early 90s. The canonical forms selected for those > processors may not be optimal for today's processors. Or, more precisely, for the back

Re: RFC: Combine of compare & and oddity

2015-09-03 Thread Jeff Law
On 09/03/2015 12:53 PM, Wilco Dijkstra wrote: Segher Boessenkool wrote: On Thu, Sep 03, 2015 at 10:09:36AM -0600, Jeff Law wrote: You will end up with a *lot* of target hooks like this. It will also make testing harder (less coverage). I am not sure that is a good idea. We certainly need a l

RE: RFC: Combine of compare & and oddity

2015-09-03 Thread Wilco Dijkstra
> Segher Boessenkool wrote: > On Thu, Sep 03, 2015 at 10:09:36AM -0600, Jeff Law wrote: > > >>You will end up with a *lot* of target hooks like this. It will also > > >>make testing harder (less coverage). I am not sure that is a good idea. > > > > > >We certainly need a lot more target hooks in

Re: RFC: Combine of compare & and oddity

2015-09-03 Thread Jeff Law
On 09/03/2015 10:18 AM, Segher Boessenkool wrote: But there are more efficient ways to emit single bit and masks tests that apply to most CPUs rather than doing something specific that works for just one target only. For example single bit test is a simple shift into carry flag or into the sign

RE: RFC: Combine of compare & and oddity

2015-09-03 Thread Wilco Dijkstra
> Oleg Endo wrote: > On 04 Sep 2015, at 01:54, Segher Boessenkool > wrote: > > > On Thu, Sep 03, 2015 at 05:25:43PM +0100, Kyrill Tkachov wrote: > >>> void g(void); > >>> void f(int *x) { if (*x & 2) g(); } > > > >> A testcase I was looking at is: > >> int > >> foo (int a) > >> { > >> return (a

Re: RFC: Combine of compare & and oddity

2015-09-03 Thread Oleg Endo
On 04 Sep 2015, at 01:54, Segher Boessenkool wrote: > On Thu, Sep 03, 2015 at 05:25:43PM +0100, Kyrill Tkachov wrote: >>> void g(void); >>> void f(int *x) { if (*x & 2) g(); } > >> A testcase I was looking at is: >> int >> foo (int a) >> { >> return (a & 7) != 0; >> } >> >> For me this genera

Re: RFC: Combine of compare & and oddity

2015-09-03 Thread Segher Boessenkool
On Thu, Sep 03, 2015 at 05:25:43PM +0100, Kyrill Tkachov wrote: > >void g(void); > >void f(int *x) { if (*x & 2) g(); } > A testcase I was looking at is: > int > foo (int a) > { > return (a & 7) != 0; > } > > For me this generates: > and w0, w0, 7 > cmp w0, wzr >

RE: RFC: Combine of compare & and oddity

2015-09-03 Thread Wilco Dijkstra
> Kyrill Tkachov wrote: > A testcase I was looking at is: > int > foo (int a) > { >return (a & 7) != 0; > } > > For me this generates: > and w0, w0, 7 > cmp w0, wzr > csetw0, ne > ret > > when it could be: > tst w0, 7 > cs

Re: RFC: Combine of compare & and oddity

2015-09-03 Thread Segher Boessenkool
On Thu, Sep 03, 2015 at 10:09:36AM -0600, Jeff Law wrote: > >>You will end up with a *lot* of target hooks like this. It will also > >>make testing harder (less coverage). I am not sure that is a good idea. > > > >We certainly need a lot more target hooks in general so GCC can do the > >right th

Re: RFC: Combine of compare & and oddity

2015-09-03 Thread Kyrill Tkachov
On 03/09/15 17:18, Segher Boessenkool wrote: On Thu, Sep 03, 2015 at 03:59:00PM +0100, Wilco Dijkstra wrote: However there are 2 issues with this, one is the spurious subreg, Combine didn't make that up out of thin air; something already used DImode here. It could simplify it to SImode in thi

Re: RFC: Combine of compare & and oddity

2015-09-03 Thread Segher Boessenkool
On Thu, Sep 03, 2015 at 03:59:00PM +0100, Wilco Dijkstra wrote: > > > However there are 2 issues with this, one is the spurious subreg, > > > > Combine didn't make that up out of thin air; something already used > > DImode here. It could simplify it to SImode in this case, that is > > true, don't

Re: RFC: Combine of compare & and oddity

2015-09-03 Thread Jeff Law
On 09/03/2015 08:59 AM, Wilco Dijkstra wrote: Segher Boessenkool wrote: On Thu, Sep 03, 2015 at 12:43:34PM +0100, Wilco Dijkstra wrote: Combine canonicalizes certain AND masks in a comparison with zero into extracts of the widest register type. During matching these are expanded into a very i

Re: RFC: Combine of compare & and oddity

2015-09-03 Thread Jeff Law
On 09/03/2015 07:18 AM, Segher Boessenkool wrote: On Thu, Sep 03, 2015 at 12:43:34PM +0100, Wilco Dijkstra wrote: Combine canonicalizes certain AND masks in a comparison with zero into extracts of the widest register type. During matching these are expanded into a very inefficient sequence t

Re: RFC: Combine of compare & and oddity

2015-09-03 Thread Jeff Law
On 09/02/2015 03:00 PM, Segher Boessenkool wrote: On Wed, Sep 02, 2015 at 01:59:58PM -0600, Jeff Law wrote: (set (reg:CC 66 cc) (compare:CC (and:DI (lshiftrt:DI (subreg:DI (reg/v:SI 76 [ xD.2641 ]) 0) (const_int 1 [0x1])) (const_int 1 [0x1])) (con

Re: RFC: Combine of compare & and oddity

2015-09-03 Thread Andrew Pinski
On Thu, Sep 3, 2015 at 10:59 PM, Wilco Dijkstra wrote: >> Segher Boessenkool wrote: >> On Thu, Sep 03, 2015 at 12:43:34PM +0100, Wilco Dijkstra wrote: >> > > > Combine canonicalizes certain AND masks in a comparison with zero into >> > > > extracts of the >> > > widest >> > > > register type. Dur

RE: RFC: Combine of compare & and oddity

2015-09-03 Thread Wilco Dijkstra
> Segher Boessenkool wrote: > On Thu, Sep 03, 2015 at 12:43:34PM +0100, Wilco Dijkstra wrote: > > > > Combine canonicalizes certain AND masks in a comparison with zero into > > > > extracts of the > > > widest > > > > register type. During matching these are expanded into a very > > > > inefficie

Re: RFC: Combine of compare & and oddity

2015-09-03 Thread Segher Boessenkool
On Thu, Sep 03, 2015 at 12:43:34PM +0100, Wilco Dijkstra wrote: > > > Combine canonicalizes certain AND masks in a comparison with zero into > > > extracts of the > > widest > > > register type. During matching these are expanded into a very inefficient > > > sequence that > > fails to > > > matc

RE: RFC: Combine of compare & and oddity

2015-09-03 Thread Wilco Dijkstra
> Segher Boessenkool wrote: > Hi Wilco, > > On Wed, Sep 02, 2015 at 06:09:24PM +0100, Wilco Dijkstra wrote: > > Combine canonicalizes certain AND masks in a comparison with zero into > > extracts of the > widest > > register type. During matching these are expanded into a very inefficient > > se

Re: RFC: Combine of compare & and oddity

2015-09-02 Thread Segher Boessenkool
On Wed, Sep 02, 2015 at 01:59:58PM -0600, Jeff Law wrote: > >(set (reg:CC 66 cc) > > (compare:CC (and:DI (lshiftrt:DI (subreg:DI (reg/v:SI 76 [ xD.2641 ]) > > 0) > > (const_int 1 [0x1])) > > (const_int 1 [0x1])) > > (const_int 0 [0]))) > Yea, this is an

Re: RFC: Combine of compare & and oddity

2015-09-02 Thread Jeff Law
On 09/02/2015 11:09 AM, Wilco Dijkstra wrote: Hi, Combine canonicalizes certain AND masks in a comparison with zero into extracts of the widest register type. During matching these are expanded into a very inefficient sequence that fails to match. For example (x & 2) == 0 is matched in combine

Re: RFC: Combine of compare & and oddity

2015-09-02 Thread Segher Boessenkool
Hi Wilco, On Wed, Sep 02, 2015 at 06:09:24PM +0100, Wilco Dijkstra wrote: > Combine canonicalizes certain AND masks in a comparison with zero into > extracts of the widest > register type. During matching these are expanded into a very inefficient > sequence that fails to > match. For example (x

RFC: Combine of compare & and oddity

2015-09-02 Thread Wilco Dijkstra
Hi, Combine canonicalizes certain AND masks in a comparison with zero into extracts of the widest register type. During matching these are expanded into a very inefficient sequence that fails to match. For example (x & 2) == 0 is matched in combine like this: Failed to match this instruction: (