Re: [PATCH] vrp: fold ffs to ctz

2012-06-05 Thread Matt Thomas
On Jun 5, 2012, at 6:46 AM, Paolo Bonzini wrote: >> Do we always have CTZ if we have FFS? Can't there be a target that >> implements FFS as opcode but not CTZ, so you'd slow down things? >> Thus, should the transform be conditonal on target support for CTZ >> or no target support for FFS? > > H

Re: [PATCH] vrp: fold ffs to ctz

2012-06-05 Thread Paolo Bonzini
Il 04/06/2012 11:31, Richard Guenther ha scritto: > +val = compare_range_with_value (NE_EXPR, vr, integer_zero_node, > &sop); > +if (!val || !integer_onep (val)) > + return false; > > please add a value_range_nonzero_p helper alongside value_range_nonnegative_p. > > +

Re: [PATCH] vrp: fold ffs to ctz

2012-06-04 Thread Richard Guenther
On Sat, Jun 2, 2012 at 1:36 PM, Paolo Bonzini wrote: > The ffs function can be converted to ctz if the operand is known not > to be zero, as is the case for example in > >    while (x != 0) { >       bit = ffs(x) - 1; >       ... >       x &= ~(1 << bit); >    } > > CSE can already do this on x86,

[PATCH] vrp: fold ffs to ctz

2012-06-02 Thread Paolo Bonzini
The ffs function can be converted to ctz if the operand is known not to be zero, as is the case for example in while (x != 0) { bit = ffs(x) - 1; ... x &= ~(1 << bit); } CSE can already do this on x86, but the attached patch implements this folding in VRP in a target-