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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
     Ever confirmed|0                           |1
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot 
gnu.org
   Last reconfirmed|                            |2023-11-21

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
```
unsigned f(unsigned a)
{
  unsigned t = a+1;
  bool tt = t > 999;
  unsigned t3 = ~a;
  unsigned t4;
  if (tt) t4 = t3; else t4 = 0;
  return t+t4;
}
```
Is only optimized by PRE.
Which does not optimize GIMPLE_COND plus it is too late.

Anyways we have:

  _6 = a_2(D) + 1;
  _7 = _6 > 999;
  _8 = ~a_2(D);
  _9 = _7 ? _8 : 0;
  a_4 = _6 + _9;

Which could be optimized to:
  _6 = a_2(D) + 1;
  _7 = _6 > 999;
  a_4 = _7 ? 0 : _6;

Maybe something like:
```
(simplify
 (plus:c (plus@0 @1 integer_onep)
         (cond @2 (bit_not @0) integer_zerop@3))
 (cond @2 @3 @0))
```

I will look into this further, maybe that is it.

Reply via email to