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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> (In reply to Andrew Pinski from comment #3)
> > Note we also don't optimize:
> > 
> > inline int sign1(int x)
> > {
> >     return (x < 0 ? -1 : 0) | (x > 0 ? 1 : 0);
> > }
> > bool f1(int x)
> > {
> >     return sign1(x) < 1;
> > }
> > 
> > To be just `x <= 0`
> 
> That is because forwprop leaves assignments that are not used anywhere still.
> after dce7:
> ```
>   if (x_2(D) < 0)
>     goto <bb 4>; [41.00%]
>   else
>     goto <bb 3>; [59.00%]
> 
>   <bb 3> [local count: 633507680]:
>   _7 = x_2(D) != 0;
>   _8 = (int) _7;
>   _5 = _8 ^ 1;
>   _10 = (bool) _5;
> 
>   <bb 4> [local count: 1073741824]:
>   # prephitmp_11 = PHI <1(2), _10(3)>
> ```
> After frowprop4:
> ```
>   if (x_2(D) < 0)
>     goto <bb 4>; [41.00%]
>   else
>     goto <bb 3>; [59.00%]
> 
>   <bb 3> [local count: 633507680]:
>   _7 = x_2(D) != 0;
>   _8 = (int) _7;
>   _3 = x_2(D) == 0;
>   _5 = (int) _3;
> 
>   <bb 4> [local count: 1073741824]:
>   # prephitmp_11 = PHI <1(2), _3(3)>
> ```
> 
> If those statements were removed then phiopt4 would be able to optimize
> prephitmp_11 to: `(x_2(D) < 0) | (x_2(D) == 0)` which simplifies to `x_2(D)
> <= 0` .
> 
> Let me look into the forwprop issue here.

That was fixed with r14-3982-g9ea74d235c7e78 .

Reply via email to