Re: [Patch match.pd] Fold (A / (1 << B)) to (A >> B)

2017-06-22 Thread James Greenhalgh
On Wed, Jun 21, 2017 at 08:59:29AM +0200, Richard Biener wrote: > Actually I was looking for a bit more generic > > bool > target_supports_op_p (tree type, enum tree_code code, > enum optab_subtype = optab_default) > { > optab ot = optab_for_tree_code (code, type, optab_subty

Re: [Patch match.pd] Fold (A / (1 << B)) to (A >> B)

2017-06-21 Thread Richard Biener
On Tue, 20 Jun 2017, James Greenhalgh wrote: > > On Fri, Jun 16, 2017 at 11:41:57AM +0200, Richard Biener wrote: > > On Fri, 16 Jun 2017, James Greenhalgh wrote: > > > On Mon, Jun 12, 2017 at 03:56:25PM +0200, Richard Biener wrote: > > > > + We can't do the same for signed A, as it might be neg

Re: [Patch match.pd] Fold (A / (1 << B)) to (A >> B)

2017-06-20 Thread James Greenhalgh
On Fri, Jun 16, 2017 at 11:41:57AM +0200, Richard Biener wrote: > On Fri, 16 Jun 2017, James Greenhalgh wrote: > > On Mon, Jun 12, 2017 at 03:56:25PM +0200, Richard Biener wrote: > > > + We can't do the same for signed A, as it might be negative, which > > > would > > > + introduce undefined b

Re: [Patch match.pd] Fold (A / (1 << B)) to (A >> B)

2017-06-16 Thread Richard Biener
On Fri, 16 Jun 2017, James Greenhalgh wrote: > > On Mon, Jun 12, 2017 at 03:56:25PM +0200, Richard Biener wrote: > > On Mon, 12 Jun 2017, James Greenhalgh wrote: > > > > > > > > Hi, > > > > > > As subject, for the testcase in the patch: > > > > > > unsigned long > > > f2 (unsigned long a, int

Re: [Patch match.pd] Fold (A / (1 << B)) to (A >> B)

2017-06-16 Thread James Greenhalgh
On Mon, Jun 12, 2017 at 03:56:25PM +0200, Richard Biener wrote: > On Mon, 12 Jun 2017, James Greenhalgh wrote: > > > > > Hi, > > > > As subject, for the testcase in the patch: > > > > unsigned long > > f2 (unsigned long a, int b) > > { > > unsigned long x = 1UL << b; > > return a / x

Re: [Patch match.pd] Fold (A / (1 << B)) to (A >> B)

2017-06-12 Thread Richard Biener
On Mon, 12 Jun 2017, James Greenhalgh wrote: > > Hi, > > As subject, for the testcase in the patch: > > unsigned long > f2 (unsigned long a, int b) > { > unsigned long x = 1UL << b; > return a / x; > } > > We currently generate: > > f2: > mov x2, 1 > lsl

[Patch match.pd] Fold (A / (1 << B)) to (A >> B)

2017-06-12 Thread James Greenhalgh
Hi, As subject, for the testcase in the patch: unsigned long f2 (unsigned long a, int b) { unsigned long x = 1UL << b; return a / x; } We currently generate: f2: mov x2, 1 lsl x1, x2, x1 udivx0, x0, x1 ret Which could instead be tr