http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55181

--- Comment #10 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to Oleg Endo from comment #9)
> 
> Maybe if-convert could be taught to transform the second if (...) to a
> zero_extract as well.  But probably it's better to catch this earlier.

... which would make the original example

unsigned char lfsr (unsigned long number)
{
  unsigned char b = 0;
  if (number & (1L << 29)) b++;
  if (number & (1L << 13)) b++;

  return b;
}

produce the same code as

unsigned char lfsr (unsigned long number)
{
  return ((number & (1L << 29)) != 0) + ((number & (1L << 13)) != 0);
}

Reply via email to