[Bug c/108370] gcc doesn't merge bitwise-AND if an explicit comparison against 0 is given

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 11 14:24:45 GMT 2023


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108370

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
ifcombine seems to assume that

     D.1987_7 = op0 & 1;
     if (D.1987_7 != 0)

is canonical but we see

  _9 = (_Bool) _6;
  if (_9 != 0)

instead.  That's already the form introduced by inlining from

_Bool bio_flagged (struct bio * bio, unsigned int bit)
{
  short unsigned int _1;
  unsigned int _2;
  unsigned int _3;
  unsigned int _4;
  _Bool _8;

  <bb 2> :
  _1 = bio_6(D)->bi_flags;
  _2 = (unsigned int) _1;
  _3 = _2 >> bit_7(D);
  _4 = _3 & 1;
  _8 = _4 != 0;
  return _8;

and

  <bb 2> :
  _1 = bio_flagged (bio_7(D), 0);
  if (_1 != 0)
    goto <bb 4>; [INV]
  else
    goto <bb 3>; [INV]


More information about the Gcc-bugs mailing list