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

            Bug ID: 107765
           Summary: missing (int)-(unsigned)int_val to just -int_val if
                    int_val is known not to contain INT_MIN
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
#include <limits.h>

int a(int input)
{
    if (input == INT_MIN) __builtin_unreachable();
    unsigned t = input;
    int tt =  -t;
    return tt == -input;
}
```
We should be able to optimize this at the tree level because we know we don't
invoke undefined behavior.

Reply via email to