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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2020-05-04 00:00:00         |2021-8-14
           Severity|normal                      |enhancement

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
  if (x_4(D) <= 0)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  iftmp.0_6 = -x_4(D);

  <bb 4> :
  # iftmp.0_3 = PHI <iftmp.0_6(3), 0(2)>

x <= 0 ? -x : 0 isn't this MAX<-x, 0>?

So there are two issues here, first is the above one, the second one is
MAX<a, 0> + MAX<-a,0> is not optimized to just MAX<-a,a> or just ABS<a>.

E.g.:
unsigned f1(int x)
{
   int t = (x >= 0 ? x : 0) ;
   int tt = -x;
   int t1 = (tt >= 0 ? tt : 0) ;
    return t + t1;
}

Reply via email to