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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot 
gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The missed optimization is:
int f(int c)
{
  unsigned t = c == 1;
  t <<= 1;
  return t == 0;
}

int f1(int c)
{
  unsigned t = c == 1;
  return ((int)t) <= 0;
}

That is (t << 1) == 0 should be convert into either:
(t & 0x7fffffff) or ((int)t) <= 0

Though the (semi more) general case is:
(for shift (lshift rshift)
 (for eqne (eq ne)
  (simplify
   (eqne (shift @0 INTEGER_CST@1) integer_zerop@2)
   (with
    {
      mask = ...
    }
    (eqne (bit_and @0 { mask; }) @2)))))

And then the mask bit_and neeq to gtle

And then the rest will just work

Reply via email to