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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> Confirmed again.
> So looking at the IR, it took until PHI-OPT4 to be able to convert it into:
>   <bb 2> [local count: 1073741824]:
>   if (x_3(D) != 0)
>     goto <bb 3>; [50.00%]
>   else
>     goto <bb 4>; [50.00%]
> 
>   <bb 3> [local count: 536870913]:
>   _1 = x_3(D) & 85;
>   _5 = _1 != 0;
>   _6 = (int) _5;
> 
>   <bb 4> [local count: 1073741824]:
>   # iftmp.0_2 = PHI <_6(3), 0(2)>

In GCC 12+, phiopt2 is able to convert that into the above.

One thing that could be tried is to replace x_3 with 0 and see if _6 would
simplify down to 0 (other the phi argument). This could be part of phiopt but
would need a lot of work really.

Note VRP is able to handle the other way around already:
that is: `(x & 0x55) && x ` But that is simplier.

Reply via email to