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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #5)
> bool0 - bool1 -> bool0 ^ bool1
> bool0 + bool1 -> bool0 ^ bool1
> 
> Also:
>   _7 = n_21 - _6;
>   _8 = _7 + 1;
>   _29 = _8 & 1;
>   expected_24 = _29 == 0;
> 
> The +1 and == 0 cancel each other out.

Well -O1 we get:
  _3 = n_21 - _2;
  _4 = _3 + 1;
  _23 = _4 & 1;
  _5 = _23 == 0;

and at -O2 we have:
  _38 = ~n_23;
  _39 = _2 + _38;
  _40 = _39 + -1;
  _5 = (bool) _40;

So we have:
(~n ^ _2 ^ 1) which is just n ^ _2. (_2 is i).

Reply via email to