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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-07-10
     Ever confirmed|0                           |1
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually it is not optimized if it was in one statement:
int8_t f1(int8_t x)
{
    return ((int8_t)(1 << x)) & 1;
}

The IR has:
  _4 = (int) x_1(D);
  _5 = 1 << _4;
  sh_6 = (int8_t) _5;
  _7 = sh_6 & 1;

We optimize directly "(1 << x) & 1" but not with a cast.

Reply via email to