Martin Liška <mli...@suse.cz> writes: > On 6/5/19 1:13 PM, Richard Biener wrote: >> On Wed, Jun 5, 2019 at 12:56 PM Martin Liška <mli...@suse.cz> wrote: >>> >>> Hi. >>> >>> I'm suggesting one multiplication simplification pattern. >>> >>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests. >>> >>> Ready to be installed? >> >> + (if (INTEGRAL_TYPE_P (type) >> + && wi::eq_p (get_nonzero_bits (@1), wi::one (TYPE_PRECISION (type))) >> + && wi::eq_p (get_nonzero_bits (@2), wi::one (TYPE_PRECISION (type)))) >> >> && wi::eq_p (wi::bit_or (get_nonzero_bits (@1), get_nonzero_bits (@2)), >> 1)) >> >> (I think literal 1 still works)? > > Yep, I can confirm that.
get_nonzero_bits (@1) == 1 should work too (without the wi::eq). > >> How does it behave for singed/unsigned 1-bit >> bitfields? A gimple testcase maybe necessary to see. > > Can we really have a mult that will have a bitfield type? FWIW, even if we can't, get_nonzero_bits returns 1-bit integers for 1-bit types (of either signedness), so the code should DTRT. Thanks, Richard